Description
给出一个浮点数c,求出使得不等式 1/2 + 1/3 + … + 1/(n+1) >= c 成立的最小n
Input
多组用例,每组用例一个浮点数,以0.00结束输入
Output
对于每组用例,输出满足条件的最小n值
Sample Input
1.00
3.71
0.04
5.19
0.00
Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)
Solution
水题
Code
#include<stdio.h>
int main()
{
int n,i;
double c,s;
while(scanf("%lf",&c),c)
{
i=0;
s=0;
for(i=2;s<c;i++)
s+=1.0/i;
printf("%d card(s)\n",i-2);
}
}