summaryrefslogtreecommitdiff
path: root/2011/qual/c/c.py
blob: b081a038b665b21e97bbf7bbc16550185777e67c (plain)
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
f = open('3.in', 'r')
o = open('3.out', 'w')

T = int(f.readline().strip())

xor = lambda x,y: x^y

for t in xrange(T):
    _n = f.readline().strip().split(' ')
    C = map(int, f.readline().strip().split(' '))

    s, p = C, []
    s.sort()
    s.reverse()
    
    p.append(s.pop())
    
    res = 'NO'
    while s:
        ss = reduce(xor, s)
        sp = reduce(xor, p)
        if ss == sp:
            res = str(sum(s))
            break
        p.append(s.pop())
    
    s = "Case #%d: %s\n" % (t+1, res)
    #print s
    o.write(s)

f.close()
o.close()