A10818 | New Password
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
- the length of the password must be equal to $n$ ,
- the password should consist only of lowercase Latin letters,
- the number of distinct symbols in the password must be equal to $k$ ,
- any two consecutive symbols in the password must be distinct.
Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
Innokentiy decides that new password should satisfy the following conditions:
- the length of the password must be equal to $n$ ,
- the password should consist only of lowercase Latin letters,
- the number of distinct symbols in the password must be equal to $k$ ,
- any two consecutive symbols in the password must be distinct.
Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
输入格式
The first line contains two positive integers $n$ and $k$ ( $2<=n<=100$ , $2<=k<=min(n,26)$ ) — the length of the password and the number of distinct symbols in it.
Pay attention that a desired new password always exists.
Pay attention that a desired new password always exists.
输出格式
Print any password which satisfies all conditions given by Innokentiy.
输入输出样例
输入 #1
4 3
输出 #1
java
输入 #2
6 6
输出 #2
python
输入 #3
5 2
输出 #3
phphp
In the first test there is one of the appropriate new passwords — java, because its length is equal to $4$ and $3$ distinct lowercase letters a, j and v are used in it.
In the second test there is one of the appropriate new passwords — python, because its length is equal to $6$ and it consists of $6$ distinct lowercase letters.
In the third test there is one of the appropriate new passwords — phphp, because its length is equal to $5$ and $2$ distinct lowercase letters p and h are used in it.
Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
In the second test there is one of the appropriate new passwords — python, because its length is equal to $6$ and it consists of $6$ distinct lowercase letters.
In the third test there is one of the appropriate new passwords — phphp, because its length is equal to $5$ and $2$ distinct lowercase letters p and h are used in it.
Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted