最大的位或 HDU

最大的位或

HDU - 5969

中文题~

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define LL long long 
 4 int main(){
 5     LL a, b;
 6     int t;
 7     //freopen("in.txt", "r", stdin);
 8     scanf("%d", &t);
 9     while(t--) {
10         scanf("%lld %lld", &a, &b);
11         LL ans = 0; 
12         int i;
13         for(i = 62; i >= 0; i--){
14             LL temp = 1LL<<i;
15             if((a&temp) == (b&temp)) {
16                 if(b&temp) {
17                     ans |= temp;
18                 }
19             }else {
20                 ans |= temp*2-1;
21                 break;
22             }
23         }
24        
25         printf("%lld
", ans);
26     }
27 }
View Code
原文地址:https://www.cnblogs.com/yijiull/p/7706184.html