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

Who solved it in mathematical way?

Posted by sehdan at 2008-12-04 19:36:50 on Problem 1003 and last updated at 2008-12-04 19:38:12
At first I wanna try to solved it in mathematical way,
Just as we all know,for the harmonic progression,while it achieve N,its sum is:
∑1/i = ln N + γ,where γ equals to lim(∑1/i - ln N)≈0.577215...
so we can try to solve the following equation:
ln N >= c-γ+1
then output N-1;
as the upper-limit just achieve 5.20,the accuracy of operation ought to be still enough.and I got all the correct answer for the test input.
but I got WA while sumbit it. I just wanna know the reason.
who can offer me an exactly explanation?
thanks.
and here is my code:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define gama 0.577215
#define e 2.718281

int main()
{
	double c,n;
	while(scanf("%lf",&c) != EOF && c != 0)
	{
		n = pow(e,c+1-gama);
		printf("%.0lf card(s)\n",--n);
	}
return 0;
}

What's more...finally I AC it still in the "stupid" way that try N one by one...

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