Wednesday 20 September 2017

Cats and Dogs Problem


Cats and Dogs


A chef is a farmer and a pet lover. He has a lot of his favorite pets cats and dogs in the barn. He does not know their exact count. But he knows that there are C cats and D dogs in the barn. Also, one day went to the field and found that there were L legs of the animals touching the ground. A chef knows that cats love to ride on the dogs. So, they might ride on the dogs, and their legs won't touch the ground and Chef would miss counting their legs. Chef's dogs are strong enough to ride at max two cats on their back.

It was a cold foggy morning when Chef did this counting. So he is now wondering whether he counted the legs properly or not. Specifically, he is wondering if there some possibility of his counting is correct. Please help Chef in finding it.


Input

The first line of the input contains an integer T denoting the number of test cases. T test cases follow.

The only line of each test case contains three space-separated integers C, D, L denoting the number of the cats, number of the dogs and number of legs of animals counted by Chef, respectively.

Output

For each test case, output a single line containing a string "yes" or "no" (both without quotes) according to the situation.


Constraints

1 ≤ T ≤ 105
0 ≤ C, D, L ≤ 109

Example

Input:

3
1 1 8
1 1 4
1 1 2

Output:

yes
yes
no

Explanation

Example 1. There are one cat and one dog. The number of legs of these animals on the ground is 8, it can be possible when both cat and dog are standing on the ground.

Example 2. There are one cat and one dog. The number of legs of these animals on the ground is 4, it can be possible if the cat will ride on the dog, so its legs won't be counted by Chef, only the dog's legs will be counted.

Example 3. There are one cat and one dog. The number of legs of these animals is 2, it can not be true at all, Chef might have made some mistake. Hence answer is "no".


Solution:


#include<stdio.h>
int main()
{
long unsigned c,d,l,t,max,min;
scanf("%d",&t);
while(t--)
{
scanf("%lu %lu %lu",&c,&d,&l); max=(c+d)*4;
if(c>(d*2)) min=(d+(c-(d*2)))*4;
else min=d*4;
if(max>=l && min<=l && (l%4==0))
printf("yes\n");
else printf("no\n");
}
return 0;

No comments:

Post a Comment