位运算,思维
圣
https://www.nowcoder.com/practice/36bea3ca457c4ce2bbb3b2059679f286
思路:我们首先要知道&的性质,简单说来就是&操作过后,结果不会变得更大。那么根据题目中的式子,我们可以大胆推测:对于每个将被的式子,比如:
来说,其结果应该就是
。那么其他将被
的式子结果就应该是
,因此最终结果就应该是所有元素的异或和
代码:
import sys
from functools import reduce
from operator import xor
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def GMI():
return map(lambda x: int(x) - 1, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
'''
def solve():
n = II()
a = LII()
print(reduce(xor, a))
# t = 1
t = II()
for _ in range(t):
solve()
#每日一题挑战#