CF1029A.Many Equal Substrings
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
给你一个由 n 个小写拉丁字母组成的字符串 t 和一个整数 k。
我们定义字符串 s 中从索引 l 到 r 的子串为 s[l…r]。
你的任务是构造一个长度尽可能小的字符串 s,使得恰好存在 k 个位置 i 满足 s[i…i+n−1]=t。换言之,你的任务是构造一个长度尽可能小的字符串 s,使得 s 中恰好有 k 个等于 t 的子串。
保证答案总是唯一的。
输入格式
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.
输入的第一行包含两个整数 n 和 k(1≤n,k≤50)—— 分别表示字符串 t 的长度和子串的数量。
输入的第二行包含字符串 t,该字符串恰好由 n 个小写拉丁字母组成。
输出格式
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.
输出满足条件的最短字符串 s,使得 s 中恰好有 k 个子串等于 t。
保证答案唯一。
输入输出样例
输入#1
3 4 aba
输出#1
ababababa
输入#2
3 2 cat
输出#2
catcat
输入解题思路,AI测评打分。不知道怎么写?