Given two integers and , what is the XOR (exclusive-or) of all numbers between and (inclusive)?
Input Specification
The first line of input is the integer , which is the number of test cases .
lines follow, with each line containing two integers and .
Output Specification
For each test case, output the (decimal) value of the XOR of all numbers between and , inclusive.
Sample Input
5
3 10
5 5
13 42
666 1337
1234567 89101112
Output for Sample Input
8
5
39
0
89998783
Comments
My wrong submission passed. Doesn't even pass sample, more test cases are probably needed.
I'm a bit confused, how is the XOR of 5 and 5 equal to 5? I thought it was 0.
It's asking you for the XOR of all numbers in the range . is the only number in the range , so the answer is 5.
TLEEEEEE ARGGGH something tells me i have to do more than just the XOR bitewise operator (^). do i?
Look for a pattern!
So there IS a pattern! ahh.....
How do you get an XOR of a multi digit number? Isn't it only for True and False?
We are looking for the bitwise XOR.
When I do that, 3 and 10 give me 9, and 5 and 5 give 0...
you are misunderstanding the problem it asks for the xor of all numbers between s and f, so for the example of 3 and 10 it would be 3 XOR 4 XOR... XOR 10
thanks