1029A.md (1277B)
1 Source: https://codeforces.com/problemset/problem/1029/A 2 3 A. Many Equal Substrings 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given a string $t$ consisting of $n$ lowercase Latin letters and an integer number $k$. 22 23 Let's define a substring of some string $s$ with indices from $l$ to $r$ as $s[l \dots r]$. 24 25 Your task is to construct such string $s$ of minimum possible length that there are exactly $k$ positions $i$ such that $s[i \dots i + n - 1] = t$. In other words, your task is to construct such string $s$ of minimum possible length that there are exactly $k$ substrings of $s$ equal to $t$. 26 27 It is guaranteed that the answer is always unique. 28 29 Input 30 31 The first line of the input contains two integers $n$ and $k$ ($1 \le n, k \le 50$) — the length of the string $t$ and the number of substrings. 32 33 The second line of the input contains the string $t$ consisting of exactly $n$ lowercase Latin letters. 34 35 Output 36 37 Print such string $s$ of minimum possible length that there are exactly $k$ substrings of $s$ equal to $t$. 38 39 It is guaranteed that the answer is always unique. 40 41 Examples 42 43 Input 44 45 ``` 46 3 4 47 aba 48 ``` 49 50 Output 51 52 ``` 53 ababababa 54 ``` 55 56 Input 57 58 ``` 59 3 2 60 cat 61 ``` 62 63 Output 64 65 ``` 66 catcat 67 ```