Lengths and Periods

시간 제한2초메모리 제한512 MB

요약
문자열에서 연속 부분문자열이 반복될 때 얻을 수 있는 최대 유리수 지수인 임계 지수를 구한다.
난이도

어려움10점 중 9점

유형
문자열, 문자열 매칭, 이분 탐색, 수학
정답자
아직 제출이 없습니다

문제

In mathematics and computer science, the critical exponent of a string describes the largest number of times its contiguous substring is repeated in a row. The trick is that it can be a fraction. For example, the critical exponent of “Mississippi” is 7/3, as it contains the substring “ississi”, which is of length 7 and period 3.

The formal definition is as follows. Let w and x be non-empty strings. x is said to occur in w with exponent α, for positive rational α, if there is a substring y in w such as y = xnx0 where xn is x repeated n times, x0 is a prefix of x, n is the integer part of α, and the length |y| is equal to α|x|. The critical exponent of w is the maximum α over all xα that occur in w.

Given a string w, find its critical exponent.

입력

The only line contains a string w — a sequence of lowercase English letters (1 ≤ |w| ≤ 200 000).

출력

Output the critical exponent of w as an irreducible fraction p/q where p and q are integers without leading zeroes.

예제2

  1. 예제 1

    입력
    mississippi
    
    예상 출력
    7/3
    
  2. 예제 2

    입력
    abab
    
    예상 출력
    2/1