-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmexor.cpp
More file actions
52 lines (51 loc) · 925 Bytes
/
Copy pathmexor.cpp
File metadata and controls
52 lines (51 loc) · 925 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
const int MAX_N = 3e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
void solve(int arr[])
{
int a, b;
cin >> a >> b;
int count = 0;
count = a;
int temp = arr[a];
if (temp == b)
cout << count << "\n";
else if ((temp ^ b) == a)
{
cout << count + 2 << "\n";
}
else
{
cout << count + 1 << "\n";
}
// if(mex>=2)
// {
// if(Xor==1)
// {
// cout<<count<<"\n";
// }
// else if(Xor!=1)
// {
// count++;
// cout<<count<<"\n";
// }
// }
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t, arr[MAX_N];
cin >> t;
for (int i = 1; i < MAX_N; i++)
{
arr[i] = (i - 1) ^ arr[i - 1];
}
while (t--)
solve(arr);
}