codeforces 1567 B. MEXor Mixup

本文介绍了codeforces 1567 B. MEXor Mixup问题,讨论如何找到具有特定MEX和XOR值的最短非负整数数组。给出了分析和解决方案,证明了最短数组的存在性和长度计算方法。
摘要由CSDN通过智能技术生成

本场比赛其他题目的题解

A. Domino Disaster
B. MEXor Mixup
C. Carrying Conundrum
D. Expression Evaluation Error
E. Non-Decreasing Dilemma

B. MEXor Mixup

开启传送门

题目描述

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

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

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

Input

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

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

Output

For each test case, output one (positive) integer — the length of the shortest array with MEX ⁡ \operatorname{MEX} MEX a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zuhiul

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值