Dyd's Blog

He who has a strong enough why can bear almost any how.

CF1567B MEXor Mixup

再挑战一下 $1000$

MEXor Mixup

略有点水,放代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bits/stdc++.h>
#define LL long long
#define STC static
using namespace std;
const int N = 3e5 + 5;

int sum[N];
void prev()
{
sum[0] = 0;
for (int i = 0; i < N; ++i)
sum[i] = sum[i - 1] ^ i;
}
int main()
{
int T, a, b;
prev();
scanf("%d", &T);
while (T--)
{
scanf("%d%d", &a, &b);
if (sum[a - 1] == b)
printf("%d\n", a);
else if ((sum[a - 1] ^ b) == a)
printf("%d\n", a + 2);
else
printf("%d\n", a + 1);
}
return 0;
}