题:http://poj.org/problem?id=1003
#include<iostream>
#define maxn 1000005
double a[maxn];
using namespace std;
int hangover( double x)
{
int i;
for (i = 1; i < maxn; i++)
a[i] = a[i - 1] + 1.0 / (i + 1);
for ( i = 1; i < maxn; i++)
if (a[i]>=x)
{
return i;
}
}
int main()
{
double x;
while (cin >> x&&x!=0.00)
{
int n=hangover(x);
cout << n << " card(s)" << endl;
}
return 0;
}