题库练习 XOR-distance
← 上一题 下一题 →

A16397 | XOR-distance

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR), and $|y|$ is [absolute value](https://en.wikipedia.org/wiki/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.

输入输出样例

输入 #1
10
4 6 0
0 3 2
9 6 10
92 256 23
165 839 201
1 14 5
2 7 2
96549 34359 13851
853686404475946 283666553522252166 127929199446003072
735268590557942972 916721749674600979 895150420120690183
输出 #1
2
1
1
164
542
5
3
37102
27934920819538516
104449824168870225
C++ 编辑器
输入
输出