1593.XOR sum

Time Limit: 1s Memory Limit: 256MB

You are given two positive integers $l$ and $r$,you shoud answer $l⊕(l+1)⊕⋯ ⊕r$,where $⊕$ denotes the bitwise $XOR$ operation. In $XOR$ operation we perform the comparison of two bits, being $1$ if the two bits are different, and $0$ if they are the same. For example:

$0101⊕0011=0110$

Note that binary code $0101,0011$ and $0110$ are $5,3$ and $6$ in decimal.

Input Format(From the terminal/stdin)

The input contain two integers $l ,r (1 ≤ l ≤ r ≤10^{18})$.

Output Format(To the terminal/stdout)

The only output line should contain a single integer.

Sample Input 1

Copy
1 2
 · \n

Sample Output 1

Copy
3
 \n

Sample Input 2

Copy
3 6
 · \n

Sample Output 2

Copy
4
 \n

Hints

$3⊕4⊕5⊕6=4$

Source: 2019 HNU新生赛

Submit

请先 登录

© 2025 FAQs