hdu4825
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=100000+10;
int n,m;
int tree[32*maxn][2];
LL val[32*maxn];
int tot;
void insert_(LL d)
{
int root=0;
for(int i=32;i>=0;i--)
{
int id=(d>>i)&1;//获得这一个bit位的值
if(!tree[root][id]) tree[root][id]=++tot;
root=tree[root][id];
}
val[root]=d;
}
LL find_(LL d)
{
int root=0;
for(int i=32;i>=0;i--)
{
int id=(d>>i)&1;
if(tree[root][id^1])
root=tree[root][id^1];///能找到跟他相反的就找
else
root=tree[root][id];///找不到的话只能找跟当前位数一样的
}
return val[root];///返回的是当前的值
}
int main()
{
int cas;
scanf("%d",&cas);
for(int tt=1;tt<=cas;tt++)
{
scanf("%d%d",&n,&m);
memset(tree,0,sizeof tree);