No.1930 XOR of Two Range
タグ : / 解いたユーザー数 74
作問者 :
Problem Statement
You are given non-negative integers $L,\ R$. Among all pairs of non-negative integers $i,\ j$, consider every pair satisfying $L \le i \le j \le R$ and $i+j\le L+R$. Find the bitwise XOR of $i+j$ over all such pairs.
Solve $T$ test cases.
Input
First, the number of test cases $T$ is given on line $1$ of the input.
$T$
Then, each test case is given in the following format.
$L$ $R$
- $1 \le T \le 10^5$
- $0 \le L \le R < 2^{50}$
- All input values are integers.
Output
For each test case, print the answer on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
4 1 4 4 10 5 5 9183938 10299934
Output
1 0 10 19483873
For test case $1$, the pairs $i,\ j$ satisfying the conditions are exactly $(i,\ j)=(1,\ 1),\ (1,\ 2),\ (1,\ 3),\ (1,\ 4),\ (2,\ 2),\ (2,\ 3)$.
Therefore, the answer is $2\oplus 3\oplus 4\oplus 5\oplus 4\oplus 5=1$ (where $\oplus$ denotes bitwise XOR).
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。