Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- while(n--) {
- long long a, b;
- cin >> a>>b;
- long long res = 0;
- for(long long i = 32; i >= 0; i--) {
- if((a & (1LL << i)) == (b & (1LL << i))) {
- res |= (a & (1LL << i));
- }
- else {
- break;
- }
- }
- cout << res << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement