Advertisement
Josif_tepe

Untitled

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