#C10418. Repeat and Truncate String

    ID: 39621 Type: Default 1000ms 256MiB

Repeat and Truncate String

Repeat and Truncate String

Given a string s and an integer k, form a new string by repeating s until its length is at least k and then truncate the repeated string to exactly k characters. Mathematically, you can consider that you need to repeat s \( n= \lceil \frac{k}{|s|} \rceil \) times to reach or exceed the length k and then take the first k characters of the resulting string.

For example, if \( s = \text{'abc'} \) and \( k = 10 \), the output should be abcabcabca.

inputFormat

The input is given via standard input (stdin) and consists of two lines. The first line contains the string s and the second line contains the integer k.

outputFormat

Output via standard output (stdout) the final string of length k obtained after repeating and truncating s.

## sample
abc
10
abcabcabca