-
Notifications
You must be signed in to change notification settings - Fork 0
/
distibuted equal coins into two chile codechef problem.txt
69 lines (55 loc) · 1.57 KB
/
distibuted equal coins into two chile codechef problem.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Chef has X coins worth 1 rupee each and Y coins worth 2 rupees each. He wants to distribute all of these X+Y coins to his two sons so that the total value of coins received by each of them is the same. Find out whether Chef will be able to do so.
Input Format
The first line of input contains a single integer T, denoting the number of testcases. The description of T test cases follows.
Each test case consists of a single line of input containing two space-separated integers X and Y.
Output Format
For each test case, print "YES" (without quotes) if Chef can distribute all the coins equally and "NO" otherwise. You may print each character of the string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).
Constraints
1≤T≤103
0≤X,Y≤108
X+Y>0
Subtasks
Subtask 1 (100 points): Original constraints
Sample Input 1
4
2 2
1 3
4 0
1 10
Sample Output 1
YES
NO
YES
NO
Explanation
Test case 1: Chef gives each of his sons 1 coin worth one rupee and 1 coin worth two rupees.
Test case 3: Chef gives each of his sons 2 coins worth one rupee.
solution
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while(t--)
{
long long x , y;
cin >> x >> y;
if(x ==0 && y % 2 == 0)
{
cout << "YES" << endl;
}
else if(x ==0 && y%2 != 0 )
{
cout << "NO" << endl;
}
else if(((x*1) + (y*2))%2 == 0)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
}