CF1567B.MEXor Mixup

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Alice gave Bob two integers aa and bb ( a>0a > 0 and b0b \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.

输入格式

The input consists of multiple test cases. The first line contains an integer tt ( 1t51041 \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 ( 1a31051 \leq a \leq 3 \cdot 10^5 ; 0b31050 \leq b \leq 3 \cdot 10^5 ) — the MEX\operatorname{MEX} and XOR\operatorname{XOR} of the array, respectively.

输出格式

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.

输入输出样例

  • 输入#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.

首页