CF1567B.MEXor Mixup
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice gave Bob two integers a and b ( a>0 and b≥0 ). Being a curious boy, Bob wrote down an array of non-negative integers with MEX value of all elements equal to a and XOR value of all elements equal to b .
What is the shortest possible length of the array Bob wrote?
Recall that the MEX (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the XOR of an array is the bitwise XOR of all the elements of the array.
输入格式
The input consists of multiple test cases. The first line contains an integer t ( 1≤t≤5⋅104 ) — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers a and b ( 1≤a≤3⋅105 ; 0≤b≤3⋅105 ) — the MEX and XOR of the array, respectively.
输出格式
For each test case, output one (positive) integer — the length of the shortest array with MEX a and XOR b . We can show that such an array always exists.
输入输出样例
输入#1
5 1 1 2 1 2 0 1 10000 2 10000
输出#1
3 2 3 2 3
说明/提示
In the first test case, one of the shortest arrays with MEX 1 and XOR 1 is [0,2020,2021] .
In the second test case, one of the shortest arrays with MEX 2 and XOR 1 is [0,1] .
It can be shown that these arrays are the shortest arrays possible.