Created
January 29, 2016 06:58
-
-
Save Abdujabbar/6d96b74d6f480f6545cc to your computer and use it in GitHub Desktop.
sansa and xor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = int(input()) | |
for i in range(t): | |
n = int(input()) | |
a = [int(x) for x in input().split()] | |
_sum = a[0] | |
for i in range(1, n): | |
_sum = _sum ^ a[i] | |
result = _sum | |
step = 2 | |
while step < n: | |
for i in range(n): | |
if n - i >= step: | |
__sum = a[i] | |
for j in range(i + 1, i + step): | |
if j < n: | |
__sum = __sum ^ a[j] | |
_sum = _sum ^ __sum | |
step += 1 | |
print(_sum ^ result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment