第二题

6 views
Skip to first unread message

王希元

unread,
Jan 2, 2019, 5:16:24 AM1/2/19
to cs10...@googlegroups.com
n=int(input())
for z in range(n):
    a=[int(i)for i in input().split()]
    def f(x,i):
        global a
        global k
       
        if k==0:
            if i==4 and x==24:
                print('YES')
                k=1
            elif i<4:
                f(x+a[i],i+1)
                f(x-a[i],i+1)
    k=0
    f(0,0)
    if k==1:
        continue
    print('NO')
Reply all
Reply to author
Forward
0 new messages