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:怎么会Time Limit Exceeded!高人指教啊。小弟菜,想了许久依然茫然……

Posted by meilufeng at 2008-09-24 21:24:43 on Problem 1003
In Reply To:怎么会Time Limit Exceeded!高人指教啊。小弟菜,想了许久依然茫然…… Posted by:crg511 at 2008-04-28 10:05:57
#include<iostream>
using namespace std;
int main()
{
	double a[1000];
	double num,total;
	int k=-1,i;
	cin>>num;
	while (num!=0.00)
	{
		double n=1;
		total=1/(n+1);
		while (total<num)
		{
			n=n+1;
			total=total+1/(n+1);
		}
		if (total>=num) 
		{
			k=k+1;
			a[k]=n;
		}
	    cin>>num;
	}
    for(i=0;i<=k;i++)
	cout<<a[i]<<" card(s)"<<endl;
    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