|
|
back to boardWhy I got WA.HELP!!!!!!!!!!!!!!!!!!!!!! Posted by kkk 18 Apr 2002 16:38 #include<stdio.h> main() { int M,N,Y,i,j,k,a[999],state; long b[750],temp; state=0; temp=0; for(i=0;i<999;i++) a[i]=0; scanf("%d%d%d",&N,&M,&Y); if(Y==1) { printf("1 "); state=1; } for(i=2;i<M;i++) { temp=0; for(k=0;k<750;k++) b[k]=0; j=N; b[749]=i; while(j>1){ for(k=749;k>=0;k--) { if(b[k]) { b[k]*=i; if(b[k]>=10000) { b[k-1]+=b[k]/10000; b[k]=b[k]%10000; } } else break; } j--; } for(k=0;k<750;k++) { if(!b[k]) continue; } for(k=k-1;k<750;k++) { temp=(b[k]+10000*temp)%M; } if(temp==Y) { a[i]=1; state=1; } } for(i=2;i<M;i++) { if(a[i]==1) { printf("%d",i); break; } } i++; for(;i<M;i++) { if(a[i]==1) printf(" %d",i); } if(!state)printf("-1"); } Re: Why I got WA.HELP!!!!!!!!!!!!!!!!!!!!!! Too complicated |
|
|