CF1567B.MEXor Mixup

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice gave Bob two integers aa and bb (a>0a \gt 0 and b≥0b \ge 0). Being a curious boy, Bob wrote down an array of non-negative integers with MEX⁡\operatorname{MEX} value of all elements equal to aa and XOR⁡\operatorname{XOR} value of all elements equal to bb.

What is the shortest possible length of the array Bob wrote?

Recall that the MEX⁡\operatorname{MEX} (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the XOR⁡\operatorname{XOR} of an array is the bitwise XOR of all the elements of the array.

爱丽丝给了鲍勃两个整数 aa 和 bb(其中 a>0a \gt 0 且 b≥0b \ge 0)。作为一个充满好奇心的男孩,鲍勃写出了一个由非负整数组成的数组,使得该数组所有元素的 MEX⁡\operatorname{MEX} 值等于 aa,且所有元素的 XOR⁡\operatorname{XOR} 值等于 bb。

鲍勃所写的数组的最短可能长度是多少?

回顾定义:数组的 MEX⁡\operatorname{MEX}(Minimum EXcluded,即“最小未出现值”)是指不属于该数组的最小非负整数;而数组的 XOR⁡\operatorname{XOR} 是指该数组中所有元素的按位异或(bitwise XOR)(参见 按位运算#异或)。

输入格式

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤5⋅1041 \leq t \leq 5 \cdot 10^4) — the number of test cases. The description of the test cases follows.

The only line of each test case contains two integers aa and bb (1≤a≤3⋅1051 \leq a \leq 3 \cdot 10^5; 0≤b≤3⋅1050 \leq b \leq 3 \cdot 10^5) — the MEX⁡\operatorname{MEX} and XOR⁡\operatorname{XOR} of the array, respectively.

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤5⋅1041 \leq t \leq 5 \cdot 10^4),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例仅一行,包含两个整数 aa 和 bb(1≤a≤3⋅1051 \leq a \leq 3 \cdot 10^5;0≤b≤3⋅1050 \leq b \leq 3 \cdot 10^5),分别表示该数组的 MEX⁡\operatorname{MEX} 值与 XOR⁡\operatorname{XOR} 值。

输出格式

For each test case, output one (positive) integer — the length of the shortest array with MEX⁡\operatorname{MEX} aa and XOR⁡\operatorname{XOR} bb. We can show that such an array always exists.

对于每个测试用例,输出一个(正)整数——即满足 MEX⁡\operatorname{MEX} 为 aa 且 XOR⁡\operatorname{XOR} 为 bb 的最短数组的长度。我们可以证明这样的数组总是存在的。

输入输出样例

  • 输入#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⁡\operatorname{MEX} 11 and XOR⁡\operatorname{XOR} 11 is [0,2020,2021][0, 2020, 2021].

In the second test case, one of the shortest arrays with MEX⁡\operatorname{MEX} 22 and XOR⁡\operatorname{XOR} 11 is [0,1][0, 1].

It can be shown that these arrays are the shortest arrays possible.

在第一个测试用例中,一个满足 MEX⁡\operatorname{MEX} 为 11 且 XOR⁡\operatorname{XOR} 为 11 的最短数组是 [0,2020,2021][0, 2020, 2021]。

在第二个测试用例中,一个满足 MEX⁡\operatorname{MEX} 为 22 且 XOR⁡\operatorname{XOR} 为 11 的最短数组是 [0,1][0, 1]。

可以证明,这些数组是可能的最短数组。

输入解题思路,AI测评打分。不知道怎么写?

首页