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 |
这个判断一直有问题,可能是runtime errorIn Reply To:请问1282为什么一直内存溢出?谢谢 Posted by:Hence at 2004-03-22 14:08:52 我有空会想办法解决一下的 > #include <stdio.h> > > int main() > { > const int max=200; > freopen("1282pku.in","r",stdin); > char a[max][max]; > char r[max]; > long int i,j,n,p; > long int t1,t2; > long int year; > scanf("%ld %ld",&n,&p); > for (i=0;i<n;i++) > for (j=0;j<p;j++) {scanf("%ld",&t1);a[i][j]=(int)t1-1;} > year=0; > for (i=0;i<n;i++) r[i]=(int)i; > while (year<1000000000) > { > t1=0;t2=year%p; > for (i=0;i<n;i++) > { > r[i]=a[r[i]][t2]; > if (i==r[i]) t1++; > } > if (t1==n) break; > year++; > } > if (year==1000000000) puts("No one knows."); else printf("%d\n",year+1); > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator