Skip to content

Instantly share code, notes, and snippets.

@lessandro
Created February 25, 2012 07:18
Show Gist options
  • Select an option

  • Save lessandro/1907198 to your computer and use it in GitHub Desktop.

Select an option

Save lessandro/1907198 to your computer and use it in GitHub Desktop.
hangover @ spoj
#include <iostream>
using namespace std;
int main()
{
double f;
for (;;) {
cin >> f;
if (f == 0.00) break;
int n = 1;
double o = 0.5;
while (o < f) {
n++;
o += 1.0/(n+1);
}
cout << n << " card(s)" << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment