Advertisement
Josif_tepe

Untitled

Mar 21st, 2023
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. const int maxn=200005;
  5. typedef long long ll;
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.    
  12.     for(int y = 0; y < n; y++) {
  13.         ll a, b;
  14.         cin >> a >> b;
  15.         ll result = 0;
  16.         for(ll i = 32; i >= 0; i--) {
  17.             if((a & (1LL << i)) == (b & (1LL << i))) {
  18.                 result |= (a & (1LL << i));
  19.             }
  20.             else {
  21.                 break;
  22.             }
  23.         }
  24.         cout << result << endl;
  25.     }
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement