Repetitive String Invention
시간 제한2초메모리 제한2048 MB
순서를 지켜 겹치지 않게 고른 두 부분 문자열의 이어붙이기가 같은 두 반쪽으로 이루어질 때, 그 경우의 수를 센다.
문제
Lulu has a string consisting of lowercase English letters. She would like to make her string Repetitive. A repetitive string has an even number of characters, and the first half of the string exactly matches the second half of the string. For example, "lulu", "abcabc" and "xx" are repetitive strings, while "xyx" and "abac" are not.
To get a repetitive string, Lulu can take two non-overlapping, non-empty substrings from her string and concatenate them together. The substrings must be concatenated in the order that they appear in her string.
She's wondering, what is the number of ways she can choose two substrings to make a repetitive string? Two ways are different if at least one of the substrings Lulu uses comes from a different part of her string.
Consider the string "aaaa".
- There are six ways for Lulu to form the repetitive string "aa": by matching each "a" with each subsequent "a" (+, +, +, +, +, +).
- There are also three ways for her to form "aaaa": "a"+"aaa", "aa"+"aa" and "aaa"+"a".
So there are nine ways for Lulu to form a repetitive string by concatenating non-overlapping, non-empty substrings of "aaaa" in order.
입력
The single line of input contains a single string (). This is Lulu's string.
출력
Output a single integer, which is the number of ways Lulu can concatenate two non-overlapping, non-empty substrings from her string in order to get a repetitive string.