6875.Finding Periods

Time Limit: 1s Memory Limit: 512MB

A period of a string is a prefix that can be used to generate the whole string by repeating the prefix. The last repetition may be partial. For example, the periods of abcabca are abc , abcabc and abcabca .

Your task is to find all period lengths of a string.

Input Format(From the terminal/stdin)

The only input line has a string of length $n$ consisting of characters a–z.

  • $1 \le n \le 10^6$

Output Format(To the terminal/stdout)

Print all period lengths in increasing order.

Sample Input

Copy
abcabca
       \n

Sample Output

Copy
3 6 7
 · · \n
Source: CSES, String Algorithms, 1733

Submit

请先 登录

© 2025 FAQs