summaryrefslogtreecommitdiff
path: root/2011/qual/c/c.py
blob: ccbc12fa40a92a8a972733d0c830c31749d413ca (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
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()    
    p.append(s.pop(0))
    
    res = 'NO'
    while s:
        ss = reduce(xor, s)
        sp = reduce(xor, p)
        if ss == sp:
            res = str(sum(s))
            break
        p.append(s.pop(0))
    
    s = "Case #%d: %s\n" % (t+1, res)
    o.write(s)

f.close()
o.close()