Lengths and Periods
Time limit2sMemory limit512 MB
Given a string of up to 200,000 lowercase letters, find its critical exponent, the largest repetition ratio of a substring, printed as an irreducible fraction.
- Level
Hard9 of 10
- Topics
- String, String matching, Divide and conquer
- Solved
- No attempts yet
Problem
In mathematics and computer science, the critical exponent of a string is the largest number of times a contiguous substring repeats in a row. The value can be a fraction. For example, the critical exponent of "Mississippi" is , because it contains the substring "ississi", which has length 7 and period 3. Let and be non-empty strings. occurs in with exponent , for a positive rational , if has a substring with , where is repeated times, is a prefix of , is the integer part of , and . The critical exponent of is the maximum over all that occur in .
Input
The only line contains a string , a sequence of lowercase English letters, where .
Output
Output the critical exponent of as an irreducible fraction , where and are integers without leading zeros.