問題一覧 > 通常問題

No.1930 XOR of Two Range

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 74
作問者 : chineristAC / テスター : first_vil
お気に入りにしたユーザー ProblemId : 6053 / 自分の提出
問題文最終更新日: 2022-05-06 21:19:07
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 342 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。