Advertisement
sherry_ahmos

Untitled

Sep 16th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. #include <string>
  5. #include <queue>
  6. #include <map>
  7. #include <set>
  8. #include <string>
  9. #include <algorithm>
  10. #include <cmath>
  11. #include <unordered_map>
  12. #include <unordered_set>
  13. #include <bits/stdc++.h>
  14.  
  15. using namespace std;
  16. #define ll long long
  17. #define nl endl
  18. #define cy cout << "YES\n"
  19. #define cn cout << "NO\n"
  20. #define sz s.size()
  21. #define allv v.begin(), v.end()
  22.  
  23. void sherry()
  24. {
  25.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  26. #ifndef ONLINE_JUDGE
  27.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  28. #endif
  29. }
  30. void solve()
  31. {
  32.     ll a, b;
  33.     cin >> a >> b;
  34.     ll c = a, x = 0;
  35.     for (int i = 0; i < a; i++)
  36.     {
  37.         x ^= i;
  38.     }
  39.     if (x == b)
  40.     {
  41.         cout << c << nl;
  42.         return;
  43.     }
  44.     x = x ^ b;
  45.     if (x == a)
  46.         c++;
  47.     cout << c + 1 << nl;
  48. }
  49. int main()
  50. {
  51.     sherry();
  52.     int t;
  53.     cin >> t;
  54.     while (t--)
  55.     {
  56.         solve();
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement