W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
In remote past there lived a tribe of Przesmyks (read it: "Pshaesmix"). They were outstanding, for those times, experts in numbers. To write numerals they used only two symbols, "" and "", whose ritual meaning is still a subject for historians' research. It is known that Przesmyks were able to write all natural numbers . They used sequences of characters "" and "" to write numerals, but for religious reasons some of such sequences were forbidden. Every year priests announced how many "" characters in a row maximally were allowed in notation of numerals. Depending on the year the bound was from 1 to 113. The way of notation of numerals was stated as follows: All legal sequences of "" and "" characters were ordered from shorter to longer ones, and sequences of the same length alphabetically (same as in in a dictionary, assuming "" preceded ""). Sequences ordered that way represented successive numbers . For example if more than one "" character in a row were not allowed, then the notation of numerals looked as follows:
0 | 4 | 8 | |
1 | 5 | 9 | |
2 | 6 | 10 | |
3 | 7 | 11 |
The notation of numerals changed according to changes in the bound. For example, when two or more "" characters in a row were allowed then the number 2 was written as "". The situation puts contemporary historians to a lot of trouble.
Write a program which:
In the first line of the standard input there are three positive integers , and , separated by single spaces, , . The number is the bound on the maximal number of "" characters in a row that may appear in the notation of numerals in the input data. The number is the bound on the maximal number of "" characters in a row that may appear in the notation of numerals that have to be written out. The number is the number of numerals that are to be converted. In the following lines there are numerals (strings of '' and ''), one per line. None of those numerals exceeds characters.
Your program should write to the standard output. It should write in the successive lines the successive numbers from the input data translated into the notation of Przesmyks according to the bound on the maximal number of "" characters in a row.
For the input data:
1 2 3 -+- -+ +-+
the correct result is:
++ -- -+-
Task author: Lukasz Kaiser.
<Submit a solution> [0/100]