SGU 275 高斯消元
2016-08-17 16:21
309 查看
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> #define LL long long using namespace std; const int maxn=110; int a[64][maxn]; int n; LL x; LL gauss() { int row,col; row=64-1; LL ans=0; for(;row>=0;row--) { col=0; ans<<=1; for(;col<n;col++)if(a[row][col]) break; if(col==n) { if(a[row] ==0) ans|=1; continue; } ans|=1; for(int r=row-1;r>=0;r--) { if(a[r][col]==0) continue; for(int j=col;j<=n;j++) a[r][j]=a[r][j]^a[row][j]; } } return ans; } int main() { while(~scanf("%d",&n)) { memset(a,0,sizeof a); for(int i=0;i<n;i++) { scanf("%lld",&x); for(int j=0;j<64;j++) if((x>>j)&1) a[j][i]=1; } for(int i=0;i<64;i++) a[i] =1; printf("%lld\n",gauss()); } return 0; }
相关文章推荐
- ACM学习历程—SGU 275 To xor or not to xor(xor高斯消元)
- SGU 275 To xor or not to xor【最大xor和 高斯消元】
- SGU 275 To xor or not to xor(高斯消元)
- SGU 275 To xor or not to xor (高斯消元)
- SGU 275 To xor or not to xor (高斯消元)
- SGU 275 To xor or not to xor (高斯消元)
- SGU 275 To xor or not to xor (贪心+高斯消元)
- sgu 275 To xor or not to xor(高斯消元判断是否有解)
- SGU 275 To xor or not to xor 高斯消元求N个数中选择任意数XORmax
- SGU-275 To xor or not to xor 高斯消元
- SGU 200. Cracking RSA(高斯消元+高精度)
- SGU 275. To xor or not to xor(高斯消元)
- SGU - 200 Cracking RSA 高斯消元
- sgu200:Cracking RSA(模意义下高斯消元求自由变元个数)
- sgu260:Puzzle(高斯消元)
- SGU 200 Cracking RSA (高斯消元)
- sgu-200 Cracking RSA(简单的高斯消元求自由变元个数)
- SGU 200 Cracking RSA (高斯消元)
- SGU 200. Cracking RSA 高斯消元
- SGU 200 Cracking RSA (高斯消元)