ACPrimer

POJ 1003 Hangover

May 16th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     double x,ans;
  5.     int i;
  6.     while(scanf("%lf",&x) && x>0)
  7.     {
  8.         ans=0.0;
  9.         for(i=2;ans<x;i++) ans+=1.0/i;
  10.         printf("%d card(s)\n",i-2);
  11.     }
  12.     return 0;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment