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

感觉对的代码AC不了,感觉错的代码却AC了,真郁闷

Posted by yunyifly at 2007-05-30 21:03:07 on Problem 1003
这是AC的代码。
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
	int card[600];
	double sum=0;
	int temp=0;
	int pretemp=0;
	int i=2;
	while(sum<5.21)
	{
		sum+=(1/double(i));
		pretemp=temp+1;
		temp=sum*100;
		for(int j=pretemp;j<=temp;j++)
		{
			card[j]=i-1;
		}
		i++;
	}
	cin>>sum;
	while(sum>0.001)
	{

		cout<<card[int(sum*100)]<<" card(s)"<<endl;
//感觉上面这句应该改成cout<<card[int(ceil(sum*100))]<<" card(s)"<<endl;
		cin>>sum;
	}
	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