프로그램 명: apio_palindrome
제한시간: 1 초
ou are given a string of lower-case Latin letters. Let us define substring’s “occurrence value” as the
number of the substring occurrences in the string multiplied by the length of the substring. For a given
string find the largest occurrence value of palindromic substrings.
Note
|s| is length of string s.
A substring of string s1s2 . . . s|s|
is any non-empty string sisi+1 . . . sj , where 1 ≤ i ≤ j ≤ |s|. Any string
is also its own substring.
A string is called palindromic, if it is read the same in either direction, from left to right and from right
to left.
In the first sample there are seven palindromic substrings a, b, c, aba, aca, bacab, abacaba.
- a has 4 occurrences in the given string, its occurrence value is 4 × 1 = 4
- b has 2 occurrences in the given string, its occurrence value is 2 × 1 = 2
- c has 1 occurrence in the given string, its occurrence value is 1 × 1 = 1
- aba has 2 occurrences in the given string, its occurrence value is 2 × 3 = 6
- aca has 1 occurrence in the given string, its occurrence value is 1 × 3 = 3
- bacab has 1 occurrence in the given string, its occurrence value is 1 × 5 = 5
- abacaba has 1 occurrence in the given string, its occurrence value is 1 × 7 = 7
So, the largest occurrence value of palindromic substrings is 7.
입력
The only line of input contains a non-empty string of lower-case Latin letters (a-z).
출력
one integer - the largest occurrence value of palindromic substrings.
입출력 예
입력
abacaba
출력
7
입력
www
출력
4
출처:apio 2014
[질/답]
[제출 현황]
[푼 후(0)]