POJ 1003: Hangover

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
double cc,over;
void init() {

}
void solve(){
    while(cin>>cc){
        if(abs(cc)<1e-5)return;
        over=0;
        int i=1;
        while(i){
            over+=1.0/(i+1);
            if(over>=cc)break;
            ++i;
        }
        cout<<i<<" card(s)"<<endl;
    }
}
int main() {
    init();
    solve();
    return 0;
}
View Code

 

posted @ 2018-07-19 16:50  RhythmLian  阅读(88)  评论(0编辑  收藏  举报