Skip to content

Instantly share code, notes, and snippets.

@Abdujabbar
Created January 29, 2016 06:59
Show Gist options
  • Save Abdujabbar/9f29cbef98a77cbd4700 to your computer and use it in GitHub Desktop.
Save Abdujabbar/9f29cbef98a77cbd4700 to your computer and use it in GitHub Desktop.
py
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