标签:style blog http color os io for ar div
题意:
分析:
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cmath> 6 #include <algorithm> 7 #define LL __int64 8 const int maxn = 100+10; 9 using namespace std; 10 int a[maxn][maxn], vis[maxn]; 11 LL b[maxn]; 12 13 int main() 14 { 15 LL ans, x; 16 int n, i, j, k; 17 b[0] = 1; 18 for(i = 1; i < 63; i++) 19 b[i] = 2*b[i-1]; 20 while(~scanf("%d", &n)) 21 { 22 ans = 0; 23 memset(vis, 0, sizeof(vis)); 24 for(i = 0; i < n; i++) 25 { 26 scanf("%I64d", &x); 27 for(j = 0; j < 63; j++) 28 if(x & b[62-j]) 29 a[j][i] = 1; 30 else 31 a[j][i] = 0; 32 } 33 for(i = 0; i < 63; i++) 34 a[i][n] = 1; 35 for(i = 0; i < 63; i++) 36 { 37 int tmp = -1; 38 for(j = 0; j < n; j++) 39 if(a[i][j] && !vis[j]) 40 { 41 tmp = j; 42 break; 43 } 44 if(tmp==-1 && a[i][n]==0) 45 ans += b[62-i]; 46 else if(tmp!=-1) 47 { 48 ans += b[62-i]; 49 for(k = i+1; k < 63; k++) 50 if(a[k][tmp]) 51 { 52 for(j = 0; j <= n; j++) 53 a[k][j] ^= a[i][j]; 54 } 55 } 56 } 57 printf("%I64d\n", ans); 58 } 59 return 0; 60 }
SGU 275 To xor or not to xor (高斯消元)
标签:style blog http color os io for ar div
原文地址:http://www.cnblogs.com/bfshm/p/3930690.html