标签:
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> #include<vector> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define ls i<<1 #define rs ls | 1 #define mid ((ll+rr)>>1) #define pii pair<int,int> #define MP make_pair typedef long long LL; const long long INF = 1e18; const double Pi = acos(-1.0); const int N = 1e3+10, M = 1e6, mod = 1e9+7, inf = 2e9; int n,a[66][N]; int main() { scanf("%d",&n); for(int i = 0; i < n; ++i) { LL x;int cnt = 0; scanf("%I64d",&x); while(x) { a[cnt++][i] = x%2; x/=2; } } for(int i = 0; i < 63; ++i) a[i][n] = 1; LL ans = 0; for(int i = 62; i >= 0; --i) { int x = -1; for(int j = 0; j < n; ++j) { if(a[i][j]) { x = j;break; } } if(x == -1 && a[i][n] == 0) { ans += 1LL<<i; } else if(x != -1) { ans += 1LL<<i; for(int k = i - 1; k >=0; --k) { if(a[k][x]) { for(int j = 0; j <= n; ++j) a[k][j] ^= a[i][j]; } } } } cout<<ans<<endl; return 0; }
SGU 275 To xor or not to xor 高斯消元求N个数中选择任意数XORmax
标签:
原文地址:http://www.cnblogs.com/zxhl/p/5916015.html