Luogu P3812 【模板】线性基
线性基板子题
#include <cstdio>
using namespace std;
#define R register
#define LL long long
LL p[52];
LL n;
inline void ins(LL x)
{
for(R int i=51;i>=0;i--)
{
if(x&(1LL<<i)) {
if(!p[i]) { p[i]=x; return ;}
else x^=p[i];
}
}
}
int main()
{
scanf("%lld",&n);
LL x,ans=0;
for(R int i=1;i<=n;i++) {
scanf("%lld",&x);
ins(x);
}
for(R int i=51;i>=0;i--) if((ans^p[i])>ans) ans^=p[i];
printf("%lld\n",ans);
return 0;
}