Serval and Brain Power
题意翻译
### 题目描述
定义一个字符串 $T$ 是好的,当且仅当存在字符串 $T'$ 和整数 $k(k\geq2)$,使得 $T$ 可以由 $k$ 个 $T'$ 首尾相接得到。
例如,字符串 $\texttt{gogogo}$ 就是好的,因为它可以由 $3$ 个字符串 $\texttt{go}$ 首尾相接得到;而 $\texttt{power}$ 就不是好的。
给定仅包含小写英文字母的字符串 $S$。
你需要求出 $S$ 最长的好的子序列(不一定连续)的长度,特别的如果 $S$ 没有好的子序列,答案为 $0$。
### 输入格式
输入一行一个小写英文字母字符串表示 $S(|S|\leq80)$。
### 输出格式
输出一行一个整数表示 $S$ 中最长的好的子序列的长度。
如果 $S$ 没有好的子序列,输出 $0$。
题目描述
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, $\texttt{gogogo}$ is powerful because it can be obtained by concatenating $\texttt{go}$ three times, but $\texttt{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.
输入输出格式
输入格式
The first line contains a single string $ S $ ( $ |S|\leq 80 $ ) consisting of lowercase English letters.
输出格式
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 $ .
输入输出样例
输入样例 #1
buaa
输出样例 #1
2
输入样例 #2
codeforcesround
输出样例 #2
6
输入样例 #3
oooooooooooaaaaeaaiaujooooooooooooo
输出样例 #3
24
输入样例 #4
zero
输出样例 #4
0
说明
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 $ .