Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <string>
- #include <queue>
- #include <map>
- #include <set>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <unordered_map>
- #include <unordered_set>
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl endl
- #define cy cout << "YES\n"
- #define cn cout << "NO\n"
- #define sz s.size()
- #define allv v.begin(), v.end()
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- int arr[500000]{};
- void solve()
- {
- ll a, b;
- cin >> a >> b;
- ll c = arr[a - 1];
- if (c == b)
- cout << a << nl;
- else
- {
- if ((b ^ c) != a)
- cout << a + 1 << nl;
- else
- cout << a + 2 << nl;
- }
- }
- int main()
- {
- sherry();
- for (int i = 1; i <= 500000; ++i)
- arr[i] = arr[i - 1] ^ i;
- int t;
- cin >> t;
- while (t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement