B. Codeforces Subsequences

                                                                 B. Codeforces Subsequences

Problem - 1368B - Codeforces

思路:子序列的数量就是codeforces对应每个字母的数量的乘积,因为题中说明至少为k个,所以我们可以考虑每次取数量最少的,并且将该字母的数量增加1,这样能够保证最小化长度

#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#define forin(i,a,n) for(int i=a;i<=n;i++)
#define forni(i,n,a) for(int i=n;i>=a;i--)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
const double eps=1e-7;
const int N=1e6+7 ,M=1e7+7 , INF=0x3f3f3f3f,mod=1e9+7;
inline ll read() {ll x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(ll)x*10+c-'0';c=getchar();} return x*f;}
void stin() {freopen("in_put.txt","r",stdin);freopen("my_out_put.txt","w",stdout);}

template<typename T> T gcd(T a,T b) {return b==0?a:gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}

int T;
ll n,m,k;
ll ans[11];
string str="codeforces";

void solve() {  
    n=read();
    
    for(int i=1;i<=10;i++) ans[i]=1;
    int l=1;
    while(true) {
        ll res=1;
        for(int i=1;i<=10;i++) res=(ll)res*ans[i];
        if(res>=n) break;
        ans[l]++;
        l++;
        if(l>10) l=1;
    }
    
    for(int i=1;i<=10;i++) {
        for(int j=1;j<=ans[i];j++) {
            printf("%c",str[i-1]);
        }
    }
    printf("\n");
}

int main() {
    // init();
    // stin();
    
    // scanf("%d",&T);
    T=1; 
    while(T--) solve();
    
    return 0;   
}          

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值