-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathxor-se.py
More file actions
35 lines (29 loc) · 684 Bytes
/
Copy pathxor-se.py
File metadata and controls
35 lines (29 loc) · 684 Bytes
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
33
34
35
#!/bin/python3
import sys
def sequence(N):
x = N % 8
if x == 0 or x == 1:
return N
if x == 2 or x == 3:
return 2
if x == 4 or x == 5:
return N+2
if x == 6 or x == 7:
return 0
def solution(L, R):
res = 0
if (R - L) % 2 == 1:
for ind in range(L+1, R+1, 2):
res ^= ind
else:
for ind in range(L+1):
res ^= ind
for ind in range(L+2, R+1, 2):
res ^= ind
return res
Q = int(input().strip())
for a0 in range(Q):
L,R = input().strip().split(' ')
L,R = [int(L),int(R)]
#print(solution(L,R))
print(sequence(L-1)^sequence(R))