0172. Number Container

Имя входного файла: contain.in
Имя выходного файла: contain.out
Ограничение по времени: 500 ms
Ограничение по памяти: 64 megabytes

Consider all MN N-digit numbers in the scale of notation with base M (leading zeros are allowed). Your task is to generate the lexicographically smallest string of digits of minimal possible length which will contain all these numbers as substrings if this string is infinitely appended to itself.

Input file

There are only two integers in input file: M and N. It is guaranteed that 2 ≤ M ≤ 10 and 1 ≤ N ≤ 10. It is always true that MN ≤ 1000000.

Output file

Output the lexcographically smallest string of minimal length which solves this task.

Examples:

contain.incontain.out
2 20011


Источник: Petrozavodsk Summer 2003. KOTEHOK's Contest, Sunday, August 31
Автор: Andrew Lopatin

Обсудить       Отправить решение



Версия для печати