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

Re:这题的数据不严啊!

Posted by JeRJupiter at 2009-09-05 00:09:41 on Problem 1003 and last updated at 2009-09-05 00:10:18
In Reply To:这题的数据不严啊! Posted by:JeRJupiter at 2009-09-05 00:02:30
> 遇到1.45的时候.输出结果为6 card(s)和5 card(s)的代码都能pass!
> 数据不够严啊.估计没有出到这样的数据!
如下的代码:

#include <stdio.h>
int main()
{
	float a;
	int n;
	float result=0;
	while(true)
	{
		scanf("%f",&a);
		if(a==0.0)
			break;
		for (n=2,result=0; result<=a; n++)	//这句这样是对的,测1.45的时候输出5
		//for (n=2,result=0; result<a; n++)	//这句居然可以pass!输出是6!
		{
			result += (float)1 / n;
		}	
		printf("%d card(s)\n",n-2);
	}
	return 0;
}

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