Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
路过的大牛帮我看看怎么错了#include<iostream> #include<stdio.h> #include<memory.h> using namespace std; int n=20; int a[25][25]; void input () { int i; int arr[25]; for (i = 0; i < 20; i++) scanf ("%d", &arr[i]); memset (a, 0, sizeof (a)); for (i = 0; i < 20; i++) { if (i == 0) { a[0][0] = a[0][1] = 1; //a[1][0]=1;// a[0][20] = arr[i]; } else if (i == 19) { a[i][18] = a[i][19] = 1; //a[18][i]=1;a[19][i]=1;// a[i][20] = arr[i]; } else { a[i][i-1]=a[i][i]=a[i][i+1] = 1; //a[i-1][i]=1;a[i+1][i]=1;// a[i][20] = arr[i]; } } } void solve() { int i,j,k,s; j=0; for(i=0;i<n&&j<n;i++,j++) { for(k=i;k<n;k++) if(a[k][j]) break; if(k==n){ i--; continue; } if(k!=i) { for(s=j;s<=n;s++) swap(a[i][s],a[k][s]); } for(k=i+1;k<n;k++) if(a[k][j]) for(s=j;s<=n;s++) a[k][s]=a[k][s]^a[i][s]; } k=i; s=0; for(i=k-1;i>=0;i--) { for(j=i+1;j<n;j++) a[i][n]^=(a[i][j]&&a[j][n]); if(a[i][n]) s++; } cout<<s<<endl; } int main() { input(); solve(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator