#P4302. [SCOI2003] 字符串折叠
[SCOI2003] 字符串折叠
Description
The definition of folding is as follows:
-
A string can be considered its own folding. Denoted as
S = S. -
X(S)is the folding of the string formed by concatenating copies ofS. Denoted asX(S) = SSSS…S. -
If
A = A',B = B', thenAB = A'B'. For example: since3(A) = AAA,2(B) = BB, we have3(A)C2(B) = AAACBB, and2(3(A)C)2(B) = AAACAAACBB.
Given a string, find its shortest folding.
For example, the shortest folding of AAAAAAAAAABABABCCD is 9(A)3(AB)CCD.
Input Format
A single line containing the string S, whose length does not exceed .
Output Format
A single line containing the length of the shortest folding.
NEERCYESYESYESNEERCYESYESYES
14
Hint
One shortest folding is 2(NEERC3(YES)).
It is guaranteed that for of the testdata, the string S consists only of uppercase letters.
Translated by ChatGPT 5
京公网安备 11011102002149号