#include<bits/stdc++.h> usingnamespace std; #define ll long long //地址指针 int indexs = 0; // 构建树如果有值1来表示 int chile[3300010][2]; // 对于每一个节点 都可以延伸为32位的字节 2E31 最大的数 bool cnt[100010]; ll maxG = INT_MIN; // 考虑 int占用 32个位(四个字节,肯定不够用) longlong占用64个字节勉强够用 voidinsert(ll x){ int cur = 0; for (int i = 32; i >= 0; i--) { int a = (x >> i) & 1; if (a == 0) { if (chile[cur][0] == 0) chile[cur][0] = ++indexs; cur = chile[cur][0]; } else { if (chile[cur][1] == 0) chile[cur][1] = ++indexs; cur = chile[cur][1]; } } // 对于一个数将他所经过的地点赋值 保证这条路径是通的 }
ll check(ll x){ int cur = 0; ll num = 0; for (int i = 32; i >= 0; i--) { int a = (x >> i) & 1; // 考虑异或运算 我们尽可能的保证位数权值大的点可以获取到 num *= 2; if (a == 1) { if (chile[cur][0] != 0) { cur = chile[cur][0]; num += 1; } else { cur = chile[cur][1]; }
} else { if (chile[cur][1] != 0) { cur = chile[cur][1]; num += 1; } else { cur = chile[cur][0]; } }
void insert(int x) { int p = 0; for (int i = 30; i >= 0; i -- ) { int &s = son[p][x >> i & 1]; if (!s) s = ++ idx; p = s; } }
int search(int x) { int p = 0, res = 0; for (int i = 30; i >= 0; i -- ) { int s = x >> i & 1; if (son[p][!s]) { res += 1 << i; p = son[p][!s]; } else p = son[p][s]; } return res; }
int main() { scanf("%d", &n); for (int i = 0; i < n; i ++ ) { scanf("%d", &a[i]); insert(a[i]); }
int res = 0; for (int i = 0; i < n; i ++ ) res = max(res, search(a[i]));