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 |
谁帮我看下,为什么总是WA呀#include<stdio.h> int main() { int a[200],b[200][200],i,year=1,p,flag,j,n,k; char s[200]; scanf("%d %d",&n,&p); getchar(); for(i=0;i<n;i++) { gets(s); j=0;k=0; while(s[k]!=NULL&&j<p) { b[i][j]=0; while(s[k]!=' '&&s[k]!=NULL) { b[i][j]*=10; b[i][j]+=(s[k]-48); k++; } k++;j++; } } for(i=0;i<n;i++) a[i]=i;j=0; while(year<=1000000000) { flag=1; for(i=0;i<n;i++) { a[i]=b[(a[i])][j]-1; if(a[i]!=i) flag=0; } if(flag) {printf("%d\n",year);break;} year++;j=(j+1)%p; } if(year>1000000000) printf("No one knows.\n"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator