-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoingame.py
More file actions
68 lines (33 loc) · 981 Bytes
/
coingame.py
File metadata and controls
68 lines (33 loc) · 981 Bytes
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
# Coin Game
# You are given two piles of coins where Pile A has x coins, and Pile B has y coins. In each turn, you can either pick 2 coins from Pile A and 1 coin from Pile B or 1 coin from Pile A and 2 coins from Pile B. Check whether it is possible to empty both the piles or not.
# Input Format
# The first line of input contains an integer T. In the next T lines, you are given two spaced separated integers x and y.
# Output Format
# Print "YES" if you can empty both the piles, otherwise print "NO".
# Constraints
# 1 <= T <= 105
# 0 <= x, y <= 107
# Example
# Input
# 3
# 1 2
# 4 2
# 8 12
# Output
# YES
# YES
# NO
# Explanation
# Self Explanatory
def empty(t,tc):
res=[]
for x,y in tc:
if (x+y)%3==0 and max(x,y)<=2*min(x,y):
res.append("YES")
else:
res.append("NO")
return res
t=int(input())
tc=[tuple(map(int,input().split())) for _ in range(t)]
res=empty(t,tc)
print("\n".join(res))