Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

系统极其郁闷的测试数据

Posted by majiavon at 2008-10-27 03:38:07 on Problem 3517
尽管题目声明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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator