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 ss(void); void bb(int p,int q); int a[202][202]; int b[200]; int k=-1; int i,j,m,n; int max=0; int s=0; int main(void) { scanf("%d%d",&m,&n); for(i=1;i<=m;i++) { for(j=0;j<n;j++) { int number; scanf("%d",&number); a[i][j]=number; } } i=1; while(i<=m) { bb(i,0); ++i; } if(s==0) printf("%d",ss()); return 0; } void bb(int p,int q) { k++; if((p==i)&&(q==0)&&(k!=0)) { if(k>max) (max=k); b[i]=k; k=-1; } else if(k>10000000) { printf("No one knows."); s=1; } else { p=a[p][q]; q=(q+1)%n; bb(p,q); } } int ss(void) { while(1) { int i=1; while(max%b[i]==0) { i++; if(i>m) { return max; } } max++; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator