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 azazasyb at 2009-08-19 07:20:22 on Problem 1607
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int n;
	cin>>n;

	cout<<"Cards  Overhang"<<endl;

	while ( n && n<100000 && n != EOF )
	{
		long double sum = 0;
		int count = 2;
		long double num = 0.5;
		int tn = n;

		while ( tn )
		{
			sum += num;

			if ( count<=2 )
				num = num/2;
			else
				num = 1.0/(count+2);

			tn--;
			count += 2;
		}

		cout<<setprecision(3);
		cout<<fixed<<showpoint;

		cout<<setw(5)<<n<<"     "<<sum<<endl;

		cin>>n;
	}



	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