Nailoong and Operations
原背景
出题人题解,个人认为 *1400。
虽然但是,为啥大家写的都这么复杂,std 真的写得很短也没判任何 corner,这题原本是 T1 啊。
注意到若
考虑到这个为
所以这样就行了。
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&-x
int x,y;
void solve(){
cin>>x>>y;
while(x){
int p=lowbit(x);
x-=p;
if(!x||!(y&p)){
y|=p;
continue;
}
int pp=lowbit(x);
if(!(y&pp)&&((y+p)&pp)) y+=p;
}
cout<<y<<endl;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
int T;cin>>T;while(T--) solve();
return 0;
}