Karl likes Codeforces and subsequences. He wants to find a string of lowercase English letters that contains at least k subsequences codeforces. Out of all possible strings, Karl wants to find a shortest one.
Formally, a codeforces subsequence of a string s is a subset of ten characters of s that read codeforces from left to right. For example, codeforces contains codeforces a single time, while codeforcesisawesome contains codeforces four times: codeforcesisawesome, codeforcesisawesome, codeforcesisawesome, codeforcesisawesome.
Help Karl find any shortest string that contains at least k codeforces subsequences.
Input
The only line contains a single integer k (1≤k≤1016).
Output
Print a shortest string of lowercase English letters that contains at least k codeforces subsequences. If there are several such strings, print any of them.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char a[20] = "codeforces";
ll cnt[20];
int main()
{
ll k;
scanf("%lld",&k);
// memset(cnt,1,sizeof(cnt));
for(int i = 0; i < 10; i++) cnt[i] = 1;
ll pos = 0;
while (1)
{
ll now = 1;
for (ll i = 0; i < 10; i++)
{
now *= cnt[i];
}
if (now >= k) break;
cnt[pos++]++;
pos %= 10;
}
for (ll i = 0; i < 10; i++)
{
for (ll j = 0; j < cnt[i]; j++)
{
printf("%c",a[i]);
}
}
printf("\n");
}