题目描述:
You are given a string t consisting of n lowercase Latin letters and an integer number k.
Let’s define a substring of some string s with indices from l to r as s[l…r].
Your task is to construct such string s of minimum possible length that there are exactly k positions i such that s[i…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.
It is guaranteed that the answer is always unique.
输入描述:
The first line of the input contains two integers n and k (1≤n,k≤50) — the length of the string t and the number of substrings.
The second line of the input contains the string t consisting of exactly n lowercase Latin letters.
输出描述:
Print such string s of minimum possible length that there are exactly k substrings of s equal to t.
It is guaranteed that the answer is always unique.
输入:
3 4
aba
3 2
cat
输出:
ababababa
catcat
题意:
给你一个长度为n,只包含小写字母的字符串t,在给你一个整数k。
一个字符串s的子串s[l,r]表示下标从l开始到r的所有字符集。
你的任务是构造一个字符串s使得有k个不同的位置i满足s[i, n+i-1] = t。换句话说你的任务是构造长度最小的字符串s满足恰好有k个不同的子串等于t。
题解:
直接搞
代码:
#