CF1567B.MEXor Mixup
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
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.
爱丽丝给了鲍勃两个整数 a 和 b(其中 a>0 且 b≥0)。作为一个充满好奇心的男孩,鲍勃写出了一个由非负整数组成的数组,使得该数组所有元素的 MEX 值等于 a,且所有元素的 XOR 值等于 b。
鲍勃所写的数组的最短可能长度是多少?
回顾定义:数组的 MEX(Minimum EXcluded,即“最小未出现值”)是指不属于该数组的最小非负整数;而数组的 XOR 是指该数组中所有元素的按位异或(bitwise XOR)(参见 按位运算#异或)。
输入格式
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.
输入包含多个测试用例。第一行包含一个整数 t(1≤t≤5⋅104),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例仅一行,包含两个整数 a 和 b(1≤a≤3⋅105;0≤b≤3⋅105),分别表示该数组的 MEX 值与 XOR 值。
输出格式
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.
对于每个测试用例,输出一个(正)整数——即满足 MEX 为 a 且 XOR 为 b 的最短数组的长度。我们可以证明这样的数组总是存在的。
输入输出样例
输入#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.
在第一个测试用例中,一个满足 MEX 为 1 且 XOR 为 1 的最短数组是 [0,2020,2021]。
在第二个测试用例中,一个满足 MEX 为 2 且 XOR 为 1 的最短数组是 [0,1]。
可以证明,这些数组是可能的最短数组。
输入解题思路,AI测评打分。不知道怎么写?