链接
http://acm.hdu.edu.cn/showproblem.php?pid=5969
题解
大数字就取原数,小数字从最高的不相等的二进制位往后全取 1 1 1
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
ll a, b, T, flag;
bitset<70> x, y, ans;
cin>>T;
while(T--)
{
cin>>a>>b;
y=a, x=b;
ans=x;
flag=false;
for(auto i=69;~i;i--)
{
if(flag)ans.set(i);
if(x.test(i) and !y.test(i))flag=true;
}
ll t=0;
for(auto i=69;~i;i--)t=(t<<1)+ans.test(i);
cout<<t<<endl;
}
return 0;
}