B. Codeforces Subsequences

B. Codeforces S

B. Codeforces Subsequences

time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

Karl likes Codeforces and subsequences. He wants to find a string of lowercase English letters that contains at least kk subsequences codeforces. Out of all possible strings, Karl wants to find a shortest one.

Formally, a codeforces subsequence of a string ss is a subset of ten characters of ss 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 kk codeforces subsequences.

Input

The only line contains a single integer kk (1≤k≤1016)1≤k≤1016).

Output

Print a shortest string of lowercase English letters that contains at least kk codeforces subsequences. If there are several such strings, print any of them.

Examples

input

Copy

1

output

Copy

codeforces

input

Copy

3

output

Copy

codeforcesss

ubsequences

=========================================================================

首先不在字母本位置上进行增加是不会获得最大效果的,最终的答案就是各个字母个数的乘积。

原来是

1 1 1 1 1 1 1 1 1 1

加1的话,放在那个位置都行

2 1 1 1 1 1 1 1 1 1

再加1的话,可以加到2,也可以加到1,但是发现加到1带来的增效更高

2 2 1 1 1  1 1 1 1 1

再增加1也是同理,即尽量让10个字母数量相同能够使得最终个数最多

那么我们就一直这样暴力循环,每个最多不到100次,10个也就不到1000次循环就能超过k

#include<iostream>
#include<cstdio>
#include<cstring>
# include<iomanip>

#include<algorithm>
#define  mo 998244353;
using namespace std;

typedef long long int ll;

ll cnt[20];

char ans(int i)
{
    string s=" codeforces";

    return s[i];
}
int main()
{

  ll n;

  cin>>n;

  for(int i=1;i<=10;i++)
  {
      cnt[i]=1;
  }

  ll now=1;

  int t=1;
  while(now<n)
  {

      now=now/cnt[t]*(cnt[t]+1);

      cnt[t]++;

      t++;

      if(t==11)
        t=1;


  }

  for(int i=1;i<=10;i++)
  {
      for(int j=1;j<=cnt[i];j++)
      {
          cout<<ans(i);
      }
  }


    return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秦三码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值