50194. Print Numbers

I'm a slow walker, but I never walk backwards.

Task Description

Write a program to print positive numbers. We want to print a positive number $n$ for $n \bmod k = t$ number of times, for a given $k$. However, there is a limit of $L$ on the number of digits we can print in a line. We will print $n$ $t$ times in the same line as the last number if that does not exceed the limit $L$. If printing $n$ in the same line does exceed the limit $L$ we check the following. If starting a new line, printing $n$ does not exceed the limit $L$, we start a new line and print $n$. If starting a new line still exceeds the limit $L$, we ignore $n$.

Input Format

The first line of input has $k$. The second line of input has $L$. The third line has multiple $n$'s to print. You need to process all $n$ until 0. All inputs are in int type.

Output Format

The output is as described as in the description.

Sample Input 1

11
10
2 14 0

Sample Output 1

22141414

Sample Input 2

11
10
11 3 14 8 0

Sample Output 2

333141414
88888888

Sample Input 3

13
10
20 1 2 8 20 17 2 0

Sample Output 3

122
88888888
1717171722

Estimated Cyclomatic Number

6.21

Discussion