Smallest Message

Problem #415

Tags: strings c-1 puzzle

Who solved this?

No translations... yet

Thanks to Mathias Kern for creating this impressively laconic puzzle!

You can send messages that consists only of the first K small letters of the English alphabet. Among the messages of minimal length that guarantee that an unknown phrase of length N is a substring of the message, find the lexicographically smallest.

Input: Two integers K and N.
Answer: Lexicographically smallest among messages of minimal length according to aforementioned rules.

Example:

input:
2 2

answer:
aabba
You need to login to get test data and submit solution.