CF1029A.Many Equal Substrings

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string tt consisting of nn lowercase Latin letters and an integer number kk .

Let's define a substring of some string ss with indices from ll to rr as s[lr]s[l \dots r] .

Your task is to construct such string ss of minimum possible length that there are exactly kk positions ii such that s[ii+n1]=ts[i \dots i + n - 1] = t . In other words, your task is to construct such string ss of minimum possible length that there are exactly kk substrings of ss equal to tt .

It is guaranteed that the answer is always unique.

输入格式

The first line of the input contains two integers nn and kk ( 1n,k501 \le n, k \le 50 ) — the length of the string tt and the number of substrings.

The second line of the input contains the string tt consisting of exactly nn lowercase Latin letters.

输出格式

Print such string ss of minimum possible length that there are exactly kk substrings of ss equal to tt .

It is guaranteed that the answer is always unique.

输入输出样例

  • 输入#1

    3 4
    aba
    

    输出#1

    ababababa
    
  • 输入#2

    3 2
    cat
    

    输出#2

    catcat
    
首页