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 |
系统极其郁闷的测试数据尽管题目声明2 ≤ n ≤ 10000, 1 ≤ k ≤ 10000, 1 ≤ m ≤ n 但不代表它不会输入不满足上述条件的数据,系统恰恰会输入k=0,m=0或m>n的数据,无论你对这样的数据做出什么判断都可以,只要不作为输出结束条件即可 #include <stdio.h> int f(int n,int s,int m) { int ans,i,r=0; for(i=2;i<=n;i++) { r=(r+m)%i; } ans=(r+s)%n; if(ans==0) ans=n; return ans; } int main() { int n,s,m; while(1) { scanf("%d %d %d",&n,&s,&m); if(n==0||s==0||m==0||s>n) break; printf("%d\n",f(n,s,m)); } return 0; } 我在第一次提交时使用if(n==0||s==0||m==0||s>n) break; 结果判wa,显然系统输入了k=0,m=0或m>n的情况 但是我做了这样的修改,居然AC了 #include <stdio.h> int f(int n,int s,int m) { int ans,i,r=0; for(i=2;i<=n;i++) { r=(r+m)%i; } ans=(r+s)%n; if(ans==0) ans=n; return ans; } int main() { int n,s,m; int count; while(1) { scanf("%d %d %d",&n,&m,&s); if(n==0 && m==0 && s==0)break; if(m==0||s==0||s>n) { printf("OJ is Bad!\n"); continue; } for(count=1;count<=m-1;count++) { s=(s-1)%n; if(s==0) s=n; } printf("%d\n",f(n,s,m)); } return 0; } 注意if(n==0 && m==0 && s==0)break; if(m==0||s==0||s>n) { printf("OJ is Bad!\n"); continue; } 大概对于k=0,m=0或m>n,系统采用了类似Special Judge的手段 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator