一、传送门
https://codeforces.com/contest/1335/problem/B
二、算法分析说明
一种符合要求的字符串具有如下的格式:
以 a 为长度的循环节,前 a - b + 1 个字符是 ‘a’,后 b - 1 个字符是 ‘b’、‘c’、‘d’、……。
不断添加该循环节,直到长度为 n 时截断。
三、AC 代码
#include<string>
#include<iostream>
#pragma warning(disable: 4996)
typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint;
typedef long long ll; typedef unsigned long long ull;
using namespace std; string s; size_t t, n, a, b;
inline void construct() {
for (;;) {
for (size_t i = 0; i < a - b + 1; ++i) { s += 'a'; if (s.size() > n)return; }
for (size_t i = 1; i < b; ++i) { s += 'a' + i; if (s.size() > n)return; }
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
cin >> t; ++t;
while (--t) {
cin >> n >> a >> b; s = " ";
construct();
cout << s.c_str() + 1 << endl;
}
return 0;
}