CF1789F.Serval and Brain Power
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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≥2 such that
T=k timesT′+T′+⋯+T′
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.
输入格式
The first line contains a single string S ( ∣S∣≤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 aa=a+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 .