• B. Codeforces Subsequences


    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 kcodeforces subsequences.

    Input

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

    Output

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

    Examples
    input
    Copy
    1
    
    output
    Copy
    codeforces
    
    input
    Copy
    3
    
    output
    Copy
    codeforcesss
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <set>
    #include <queue>
    #include <map>
    #include <sstream>
    #include <cstdio>
    #include <cstring>
    #include <numeric>
    #include <cmath>
    #include <iomanip>
    #include <deque>
    #include <bitset>
    //#include <unordered_set>
    //#include <unordered_map>
    #define ll              long long
    #define pii             pair<int, int>
    #define rep(i,a,b)      for(int  i=a;i<=b;i++)
    #define dec(i,a,b)      for(int  i=a;i>=b;i--)
    #define forn(i, n)      for(int i = 0; i < int(n); i++)
    using namespace std;
    int dir[4][2] = { { 1,0 },{ 0,1 } ,{ 0,-1 },{ -1,0 } };
    const long long INF = 0x7f7f7f7f7f7f7f7f;
    const int inf = 0x3f3f3f3f;
    const double pi = 3.14159265358979323846;
    const double eps = 1e-6;
    const int mod = 1e9 + 7;
    const int N = 3e3 + 5;
    //if(x<0 || x>=r || y<0 || y>=c)
    
    inline ll read()
    {
        ll x = 0; bool f = true; char c = getchar();
        while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
        while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
        return f ? x : -x;
    }
    ll gcd(ll m, ll n)
    {
        return n == 0 ? m : gcd(n, m % n);
    }
    ll lcm(ll m, ll n)
    {
        return m * n / gcd(m, n);
    }
    bool prime(int x) {
        if (x < 2) return false;
        for (int i = 2; i * i <= x; ++i) {
            if (x % i == 0) return false;
        }
        return true;
    }
    ll qpow(ll m, ll k, ll mod)
    {
        ll res = 1, t = m;
        while (k)
        {
            if (k & 1)
                res = res * t % mod;
            t = t * t % mod;
            k >>= 1;
        }
        return res;
    }
    bool check(string s,string s1)
    {
        int cnt = 0;
        forn(i, s.size())
        {
            if (s[i] != s1[i])
                cnt++;
        }
        if (cnt > 1)
            return false;
        return true;
    }
    int main()
    {
        ll n;
        string s="codeforces";
        cin >> n;
        ll m;
        rep(i, 1, 40)
        {
            ll a = 1;
            rep(j, 1, 10)
            {
                a *= i;
            }
            if (a > n)
            {
                m = i - 1;
                break;
            }
        }
        ll a=1;
        vector<int> cnt(10, m);
        rep(i, 1, 10)
            a *= m;
        int pos = 0;
        while (a < n)
        {
            a /= m;
            a *= m + 1;
            cnt[pos]++;
            pos++;
        }
        forn(i, 10)
        {
            forn(j, cnt[i])
                cout << s[i];
        }
        return 0;
    }
  • 相关阅读:
    最大子段和问题
    moore voting algorithm for majority element in vector
    linux命令 wget
    一道简单的局部链表反转的问题,具体解决时的麻烦的分类
    20145215《网络对抗》Exp2 后门原理与实践
    20145215《网络对抗》shellcode注入&Return-to-libc攻击深入
    20145215卢肖明《网络对抗》逆向及Bof基础
    20145215《信息安全系统设计基础》课程总结
    20145215&20145307《信息安全系统设计基础》实验五 网络通信
    20145215《信息安全系统设计基础》第十四周学习总结
  • 原文地址:https://www.cnblogs.com/dealer/p/13190769.html
Copyright © 2020-2023  润新知