POJ 1003 Hangover

题目:http://poj.org/problem?id=1003

   模拟题,比1002简单好多...

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstdlib>

using namespace std;

int main()
{
    while(1)
    {
        float len;
        cin>>len;
        if(len==0) break;
        float temp=0;
        int i=0;
        for(i=1;i<500;i++)
        {
            temp+=1.0/(i+1);
            if(temp>=len) break;
        }
        cout<<i<<" card(s)"<<endl;
    
    }
}

 

posted @ 2013-01-30 23:52  Daniel Qiu  阅读(118)  评论(0编辑  收藏  举报