Codeforces Round 853 (Div. 2)
F
Serval and Brain Power
Codeforces
2700
原题
← E→
翻译中…

Serval loves Brain Power and his brain power problem.

翻译中…

Serval defines that a string $T$ is powerful iff $T$ can be obtained by concatenating some string $T'$ multiple times. Formally speaking, $T$ is powerful iff there exist a string $T'$ and an integer $k\geq 2$ such that $$T=\underbrace{T'+T'+\dots+T'}_{k\text{ times}}$$

翻译中…

For example, gogogo is powerful because it can be obtained by concatenating go three times, but power is not powerful.

翻译中…

Serval has a string $S$ consists of lowercase English letters. He is curious about the longest powerful subsequence of $S$, and he only needs you to find out the length of it. If all the non-empty subsequences of $S$ is not powerful, the answer is considered to be $0$.

翻译中…

A string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly, zero or all) characters.

翻译中…

Input

翻译中…

The first line contains a single string $S$ ($|S|\leq 80$) consisting of lowercase English letters.

翻译中…

Output

翻译中…

Print a single integer — the length of the longest powerful subsequence of $S$. If all the non-empty subsequences of $S$ is not powerful, print $0$.

翻译中…

Note

翻译中…

For the first sample, all of the non-empty subsequences of buaa are listed below:

翻译中…
  • b
  • u
  • a (occurred twice, buaa and buaa)
  • bu
  • ba (occurred twice, buaa and buaa)
  • ua (occurred twice, buaa and buaa)
  • aa
  • bua (occurred twice, buaa and buaa )
  • baa
  • uaa
  • buaa
翻译中…

Since $\texttt{aa} = \texttt{a} + \texttt{a}$, aa is a powerful subsequence. It can be shown that aa is the only powerful subsequence among them. So the answer is $2$.

翻译中…

For the second sample, the longest powerful subsequence is codcod from codeforcesround. So the answer is $6$.

翻译中…

样例

Input #1
buaa
Output #1
2
InputCopy OutputCopy
Input #2
codeforcesround
Output #2
6
InputCopy OutputCopy
Input #3
oooooooooooaaaaeaaiaujooooooooooooo
Output #3
24
InputCopy OutputCopy
Input #4
zero
Output #4
0
InputCopy OutputCopy
题目信息
题号
1789F
时间限制
2 s
内存限制
256 MB
标签
位运算
暴力
动态规划
贪心
模拟
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。