308390: CF1511D. Min Cost String

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Min Cost String

题意翻译

定义一个字符串 $s$ 的花费(cost)为满足 ```cpp s[i]==s[j] && s[i+1]==s[j+1] ``` 的数对 $(i,j)$ 的数量 ($0 \leq i < j < |s|-1$) 现在需要使用从小写字母 $a$ 开始的 $k$ 种字符,构造一个长度为 $n$ 的字符串,且要求花费最小。 本题spj,如果有多种情况输出任意一种即可,数据范围见原题。

题目描述

Let's define the cost of a string $ s $ as the number of index pairs $ i $ and $ j $ ( $ 1 \le i < j < |s| $ ) such that $ s_i = s_j $ and $ s_{i+1} = s_{j+1} $ . You are given two positive integers $ n $ and $ k $ . Among all strings with length $ n $ that contain only the first $ k $ characters of the Latin alphabet, find a string with minimum possible cost. If there are multiple such strings with minimum cost — find any of them.

输入输出格式

输入格式


The only line contains two integers $ n $ and $ k $ ( $ 1 \le n \le 2 \cdot 10^5; 1 \le k \le 26 $ ).

输出格式


Print the string $ s $ such that it consists of $ n $ characters, each its character is one of the $ k $ first Latin letters, and it has the minimum possible cost among all these strings. If there are multiple such strings — print any of them.

输入输出样例

输入样例 #1

9 4

输出样例 #1

aabacadbb

输入样例 #2

5 1

输出样例 #2

aaaaa

输入样例 #3

10 26

输出样例 #3

codeforces

Input

题意翻译

定义一个字符串 $s$ 的花费(cost)为满足 ```cpp s[i]==s[j] && s[i+1]==s[j+1] ``` 的数对 $(i,j)$ 的数量 ($0 \leq i < j < |s|-1$) 现在需要使用从小写字母 $a$ 开始的 $k$ 种字符,构造一个长度为 $n$ 的字符串,且要求花费最小。 本题spj,如果有多种情况输出任意一种即可,数据范围见原题。

加入题单

算法标签: