#P8739. [蓝桥杯 2020 国 C] 重复字符串

[蓝桥杯 2020 国 C] 重复字符串

Problem Description

If a string SS can be obtained exactly by repeating some string KK times, then we call SS a KK-times repeated string. For example, abcabcabc can be seen as repeating abc for 33 times, so abcabcabc is a 33-times repeated string.

Similarly, aaaaaa is a 22-times repeated string, a 33-times repeated string, and also a 66-times repeated string.

Now given a string SS, please compute the minimum number of characters that need to be modified so that SS becomes a KK-times repeated string.

Input Format

The first line contains an integer KK.

The second line contains a string SS consisting only of lowercase letters.

Output Format

Output an integer as the answer. If SS cannot be modified into a KK-times repeated string, output 1-1.

2
aabbaa
2

Hint

Constraints: 1K1051 \le K \le 10^5, 1S1051 \le |S| \le 10^5. Here S|S| denotes the length of SS.

Lanqiao Cup 2020 National Contest Group C, Problem G.

Translated by ChatGPT 5