luogu#P4391. [BalticOI 2009] Radio Transmission 无线传输

    ID: 3338 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>字符串2009前缀和KMP 算法BalticOI(波罗的海)

[BalticOI 2009] Radio Transmission 无线传输

Problem Description

You are given a string s1s_1 that is formed by repeatedly concatenating some string s2s_2 (guaranteed to repeat at least 22 times). However, s2s_2 is unknown. You only need to determine the shortest possible length of s2s_2.

Input Format

The first line contains an integer LL, which is the length of the given string.

The second line contains a substring of s1s_1, consisting entirely of lowercase letters.

Output Format

Output a single line containing the shortest length of s2s_2.

8
cabcabca
3

Hint

Explanation for Sample Input/Output 1

For the sample, we can obtain abcabcabcabc\texttt{abcabcabcabc} by repeatedly concatenating abc\texttt{abc}. The input cabcabca\texttt{cabcabca} is its substring.

Constraints

For all test points, it is guaranteed that 1L1061 \le L \le 10^6.

Translated by ChatGPT 5