A12361 | Uniform String
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two integers $n$ and $k$ .
Your task is to construct such a string $s$ of length $n$ that for each $i$ from $1$ to $k$ there is at least one $i$ -th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to maximize the minimal frequency of some letter (the frequency of a letter is the number of occurrences of this letter in a string). If there are several possible answers, you can print any.
You have to answer $t$ independent queries.
Your task is to construct such a string $s$ of length $n$ that for each $i$ from $1$ to $k$ there is at least one $i$ -th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to maximize the minimal frequency of some letter (the frequency of a letter is the number of occurrences of this letter in a string). If there are several possible answers, you can print any.
You have to answer $t$ independent queries.
输入格式
The first line of the input contains one integer $t$ ( $1 \le t \le 100$ ) — the number of queries.
The next $t$ lines are contain queries, one per line. The $i$ -th line contains two integers $n_i$ and $k_i$ ( $1 \le n_i \le 100, 1 \le k_i \le min(n_i, 26)$ ) — the length of the string in the $i$ -th query and the number of characters in the $i$ -th query.
The next $t$ lines are contain queries, one per line. The $i$ -th line contains two integers $n_i$ and $k_i$ ( $1 \le n_i \le 100, 1 \le k_i \le min(n_i, 26)$ ) — the length of the string in the $i$ -th query and the number of characters in the $i$ -th query.
输出格式
Print $t$ lines. In the $i$ -th line print the answer to the $i$ -th query: any string $s_i$ satisfying the conditions in the problem statement with constraints from the $i$ -th query.
输入输出样例
输入 #1
3 7 3 4 4 6 2
输出 #1
cbcacab abcd baabab
In the first example query the maximum possible minimal frequency is $2$ , it can be easily seen that the better answer doesn't exist. Other examples of correct answers: "cbcabba", "ccbbaaa" (any permutation of given answers is also correct).
In the second example query any permutation of first four letters is acceptable (the maximum minimal frequency is $1$ ).
In the third example query any permutation of the given answer is acceptable (the maximum minimal frequency is $3$ ).
In the second example query any permutation of first four letters is acceptable (the maximum minimal frequency is $1$ ).
In the third example query any permutation of the given answer is acceptable (the maximum minimal frequency is $3$ ).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted