简单模拟。

CODE:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;


int get(double aim)
{
    int i;
    double s = 0;
    for(i = 1; ; i++)
    {
        if(s >= aim)
        {
            return i;
            break;
        }
        s += 1.0/(i+1.0);
    }
}


int main()
{
    double aim;
    while(~scanf("%lf", &aim))
    {
        if(aim == 0.00break;
        printf("%d card(s)\n"get(aim)-1);
    }
    return 0;

} 

posted on 2012-08-23 15:14  有间博客  阅读(140)  评论(0编辑  收藏  举报