// 报名算法课第一次自己写代码
算法
打表+贪心+字典树
C++ 代码
#include<bits/stdc++.h>
using namespace std;
const int N = 4000000 + 10;
int son[N][2] , cnt[N];
typedef long long ll;
ll idx;
ll j,maxn,me;
char str[N];
ll a[N];
int ki[100010][40],num;
void insert(int *b){
int p = 0;
for(int i=0;i<31 ; i++){
int u = b[i];
if(!son[p][u]) {
son[p][u] = ++idx;
}
p = son[p][u];
}
}
ll query(int *b){
ll maxn =0;
int p = 0;
for(int i=0;i<31;i++){
int u =!b[i] ;
if(!son[p][u]) {
u = !u;
maxn *= 2;
}
else{
maxn = maxn*2 + 1;
}
p = son[p][u];
}
return maxn;
}
int chai(int index,ll k){
num = 0;
for(int i=30;i>=0;i--){
int h = k>>i&1;
ki[index][num++] = h;
}
return 0;
}
int main(void){
std::ios::sync_with_stdio(false);
cin.tie(0);
int m;
cin>>m;
for(int i=0;i<m;i++){
cin>>a[i];
chai(i,a[i]);
insert(ki[i]);
}
ll res = 0;
for(int i=0;i<m;i++){
res = max(res ,query(ki[i]));
}
cout<<res<<endl;
}