Codeforces Round 922 (Div. 2) |
---|
Finished |
You are given integers $$$a$$$, $$$b$$$, $$$r$$$. Find the smallest value of $$$|({a \oplus x}) - ({b \oplus x})|$$$ among all $$$0 \leq x \leq r$$$.
$$$\oplus$$$ is the operation of bitwise XOR, and $$$|y|$$$ is absolute value of $$$y$$$.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
Each test case contains integers $$$a$$$, $$$b$$$, $$$r$$$ ($$$0 \le a, b, r \le 10^{18}$$$).
For each test case, output a single number — the smallest possible value.
104 6 00 3 29 6 1092 256 23165 839 2011 14 52 7 296549 34359 13851853686404475946 283666553522252166 127929199446003072735268590557942972 916721749674600979 895150420120690183
2 1 1 164 542 5 3 37102 27934920819538516 104449824168870225
In the first test, when $$$r = 0$$$, then $$$x$$$ is definitely equal to $$$0$$$, so the answer is $$$|{4 \oplus 0} - {6 \oplus 0}| = |4 - 6| = 2$$$.
In the second test:
Therefore, the answer is $$$1$$$.
In the third test, the minimum is achieved when $$$x = 1$$$.
Name |
---|