Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/db07010b277a74026ca3fa2e6aa30091 to your computer and use it in GitHub Desktop.
Save completejavascript/db07010b277a74026ca3fa2e6aa30091 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
const int MAX = 1000000;
float a[MAX]; // Độ dài khi xếp n quân bài
float F(int n)
{
float f = 0.0f;
for(int i = 2; i <= n+1; i++)
f += 1.0f/i;
return f;
}
int main()
{
//freopen("input.txt","r",stdin);
ios::sync_with_stdio(false);
for(int i = 0; i < MAX; i++)
a[i] = -1;
float c = 0.0f;
while(true)
{
cin >> c;
if(c == 0.00) break;
for(int i = 0; i < MAX; i++)
{
float f = 0.0f;
if(a[i] < 0)
{
f = F(i);
a[i] = f;
}
else f = a[i];
if(f > c)
{
cout << i << " card(s)" << endl;
break;
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment