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 |
HELP我测试是正确的阿。怎么总是wrong answer? 我的程序如下: #include<stdio.h> int sort(int n,int z,long k,int m,int *mm) { int i,j; for(i=0;i<=n;i++) { for(j=1;j<=m;j++) if((1+i*k)%n==mm[j]) return 0; if(z==(1+i*k)%n) return 1; } } int main() { int n,z,m,i; int k; int mm[1000]; scanf("%d%d%d",&n,&z,&m); for(i=1;i<=m;i++) {scanf("%d",&mm[i]); if(mm[i]==n) mm[i]=0; } if(m==0) {printf("1\n");return 0;} if(z==n) z=0; for(k=1;k<n;k++) if(sort(n,z,k,m,mm)) break; printf("%d\n",k); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator