CF219A.k-String
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.
You are given a string s, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.
如果一个字符串可以表示为某个字符串的 k 次连接(即重复拼接),则称其为 k-字符串。例如,字符串 "aabaabaabaab" 同时是一个 1-字符串、2-字符串和 4-字符串,但它不是 3-字符串、5-字符串、6-字符串等。显然,任意字符串都是一个 1-字符串。
给定一个仅由小写英文字母组成的字符串 s 和一个正整数 k。你的任务是重新排列字符串 s 中的字母,使得所得字符串是一个 k-字符串。
输入格式
The first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s.
第一行输入包含整数 k(1 ≤ k ≤ 1000)。第二行输入字符串 s,s 中所有字符均为小写英文字母。字符串 s 的长度 ∣s∣ 满足不等式 1 ≤ ∣s∣ ≤ 1000,其中 ∣s∣ 表示字符串 s 的长度。
输出格式
Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them.
If the solution doesn't exist, print "-1" (without quotes).
以某种方式重新排列字符串 s 中的字母,使得结果是一个 k-字符串。将结果输出在单独一行上。如果存在多种解,输出任意一种即可。
如果无解,则输出 -1(不带引号)。
输入输出样例
输入#1
2 aazz
输出#1
azaz
输入#2
3 abcabcabz
输出#2
-1
输入解题思路,AI测评打分。不知道怎么写?