题目:
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.
Examples
Input
1
Output
codeforces
Input
3
Output
codeforcesss
题解:
不要一直加s!!
每加一个字母,按乘积变化
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<sstream>
#include<vector>
#include<ctime>
#include<list>
#define int long long
using namespace std;
int con[15];
signed main()
{
string s="codeforces";
int n;
cin>>n;
for(int i=0;i<10;i++) con[i]=1;
int ret=0;
while(1)
{
int a=1;
for(int i=0;i<10;i++) a*=con[i];
if(a>=n) break;
con[ret++]++;
ret%=10;
}
for(int i=0;i<10;i++)
{
for(int j=0;j<con[i];j++)
{
cout<<s[i];
}
}
cout<<endl;
return 0;
}