String Exponentiation
Time limit1sMemory limit256 MB
Given a string, find the largest exponent n such that the string is a repetition of some base string a raised to n.
- Level
Medium5 of 10
- Topics
- String, String matching, Number theory
- Solved
- No attempts yet
Problem
For two strings and made of lowercase letters, denotes their concatenation. For example, if and , then .
If we treat this concatenation as multiplication, we can also define exponentiation by a non-negative integer:
- (the empty string)
Given a string , write a program that finds the largest for which some string satisfies .
Input
The input consists of at most 10 test cases. Each test case is a single line containing the string . The length of is at least 1 and at most 1,000,000. The line following the last test case contains a single period (.).
Output
For each test case, print on its own line the largest such that .