HDU 1056 HangOver

水题~

int cmp(double a,double b)
{
    if(fabs(a-b) < eps) return 0;
    return a>b?1:-1;
}

int main()
{
    double x;
    while(~scanf("%lf",&x))
    {
        if(!cmp(x,0)) break;
        double res=0;
        int cnt=0;
        int d=2;
        while(true)
        {
            if(cmp(res,x)>=0) break;
            ++cnt;
            res+=1.0/d++;
        }
        printf("%d card(s)\n",cnt);
    }
    //system("pause");
}
posted @ 2020-12-17 10:53  Dazzling!  阅读(81)  评论(0编辑  收藏  举报