Skip to content

Commit

Permalink
Problem HANGOVER from SPOJ
Browse files Browse the repository at this point in the history
  • Loading branch information
mani1996 committed Oct 5, 2016
1 parent f3ff67d commit 28352b9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions HANGOVER.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Problem : HANGOVER from SPOJ

#include <bits/stdc++.h>
using namespace std;
#define ld long double

ld dp[1001];

void compute(){
dp[0] = 0.0;
int i;
for(i=1;i<=1000;i++){
dp[i] = dp[i-1] + (1/ (ld) (i+1));
}

return ;
}

int main(){
compute();
ld x;
scanf("%Lf", &x);

while(x!=0.0){
printf("%ld card(s)\n",lower_bound(dp,dp+1001,x)-dp);
scanf("%Lf", &x);
}
}

0 comments on commit 28352b9

Please sign in to comment.