首页 > 其他分享 >Educational Codeforces Round 107 D

Educational Codeforces Round 107 D

时间:2022-10-19 00:22:05浏览次数:43  
标签:Educational const int Codeforces 显然 return 107

D. Min Cost String

显然我们对于每两个组 都要本质不同
我们考虑本质不同两个组的数量为k^2
我们考虑如何构造将这k^2的连接起来
不然显然如果一个借着一个显然会产生新的组别
我们需要的就是两个组之间都会由相交
这样不会才不会产生新组
意思就是我们由k^2个组 我们考虑如何构造将他们连接在一起构成一个k^2+1的链
显然对于a 我们就可以加上 ab ac ad ...
b bc bd ...
这样构造显然是不重不漏地

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
const int M = 998244353;
const int mod = 1e9+7;
#define int long long
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define _ 0
#define pi acos(-1)
#define INF 0x3f3f3f3f3f3f3f3f
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);

void solve() {
    int n,k;cin>>n>>k;
    string s;
    for(int i=0;i<k;i++){
        s.push_back(i+'a');
        for(int j=i+1;j<k;j++){
            s.push_back(i+'a');
            s.push_back(j+'a');
        }
    }
    for(int i=0;i<n;i++){
        cout<<s[i%s.size()];
    }
}
signed main(){
    fast
    int t;t=1;//cin>>t;
    while(t--) {
        solve();
    }
    return ~~(0^_^0);
}

标签:Educational,const,int,Codeforces,显然,return,107
From: https://www.cnblogs.com/ycllz/p/16804739.html

相关文章