Logo
(追記) (追記ここまで)

31315번 - String 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB14000.000%

문제

The Research Institute of the Given Strings (RIGS) is investigating a new method of infinite string construction.

Initially there is an empty string $S_{0}^{(k)} = \varepsilon$. Each next version of the string is created in the following way. The current version of the string is repeated $k$ times, and an arbitrary symbol is inserted between every two consecutive occurences. The same number $k$ is used for the construction of all versions, however, the inserted symbols may differ. This construction ultimately results in the infinite string $S_{\infty}^{(k)}$.

To illustrate, let's consider the series of strings ($k = 3$): $$\begin{align*} S_{0}^{(3)} &= \varepsilon (\text{empty})\\ S_{1}^{(3)} &= \mathbf{r}\mathbf{t} \hspace{5cm} ( S_{1}^{(3)} = \boxed{\varepsilon}\mathbf{r}\boxed{\varepsilon}\mathbf{t}\boxed{\varepsilon} ) \\ S_{2}^{(3)} &= \boxed{rt} \mathbf{x} \boxed{rt} \mathbf{r} \boxed{rt} \\ S_{3}^{(3)} &= \boxed{rtxrtrrt} \mathbf{a} \boxed{rtxrtrrt} \mathbf{r} \boxed{rtxrtrrt} \\ \phantom{S_{i}^{(3)}} & \ldots \\ S_{\infty}^{(3)} &= rtxrtrrtartxrtrrtrrtxrtrrtzrtxrtrrtartxrt\ldots \end{align*}$$

Given a string $A$ of length $n,ドル which is the prefix of $S_{\infty}^{(k)},ドル find the minimal $k,ドル for which this is possible.

In other words, your task is to find the minimal $k,ドル for which it is possible to construct a string $S_{\infty}^{(k)}$ in a way described above, so that it will have $A$ as a prefix.

입력

Each input file contains several tests. The first line of the file contains a single integer $T$ --- the number of tests. Then $T$ lines follow; each line describes a single test. The tests are nonempty and contain only lowercase Latin letters.

The number of tests does not exceed 10ドル^5$. The sum of lengths of all the tests in the file does not exceed 10ドル^6$.

출력

The output file must contain exactly $T$ lines. Each line must contain the minimal value of $k$ for the corresponding test.

제한

예제 입력 1

2
abacabab
rtxrtrrtartxrtrrtrrtxrt

예제 출력 1

2
3

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 2: Grand Prix of Siberia C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /