Untitled

 avatar
unknown
python
a year ago
1.4 kB
5
Indexable
def solve(a, b, c):
    cards = [a, b, c]
    count0 = 0
    for x in cards:
        if x == 0:
            count0 += 1
    
    if count0 == 2:
        for x in cards:
            if x == 1:
                return True
    
    if count0 == 1:
        firstmax, secondmax = -1, -1
        idxfirst, idxsecond = -1, -1
        for i, x in enumerate(cards):
            if x > firstmax:
                firstmax = x
                idxfirst = i
        for i, x in enumerate(cards):
            if x != 0 and i != idxfirst and x > secondmax:
                secondmax = x
                idxsecond = i
        
        if firstmax == 1 or secondmax == 1:
            return True
        if firstmax == secondmax != 1:
            return False
        else:
            r = firstmax % secondmax
            if r == 1:
                return True
            else:
                if r != 0 and secondmax % r == 1:
                    return True
            
    if count0 == 0:
        ans1 = solve(a+min(b,c), b-min(b,c), c-min(b,c))
        ans2 = solve(a-min(a,c), b+min(a,c), c-min(a,c))
        ans3 = solve(a-min(a,b), a-min(a,b), c+min(a,b))
        return ans1 or ans2 or ans3
    return False
    

# n = int(input())
# for _ in range(n):
#     a, b, c = map(int, input().split())
#     predict = bruteforce(a, b, c)
#     if predict:
#         print("Yes")
#     else:
#         print("No")
Editor is loading...
Leave a Comment