HOJ 1637 HangOver

来源:互联网 发布:淘宝老板 编辑:程序博客网 时间:2024/04/30 11:26

http://acm.hit.edu.cn/hoj/problem/view?id=1637

#include <stdio.h>#include <math.h>int fun(double c);int main(){    double c;        while (scanf("%lf", &c) && c)    {        printf("%d card(s)\n", fun(c));    }        return 0;}int fun(double c){    int i;    double s;    s = 0;    for (i = 2;;i++)    {        s += pow(i, -1.0);        if(s >= c)        break;    }    return i - 1;}


 

原创粉丝点击