spoj#PRJAN15C. String Play
String Play
String Play
Milo has a string S of length L. Tutu picks a random prefix and Mota picks a random suffix of S.
Now, Chotku is given a task of concatenating the two strings that Tutu and Mota have chosen, in respective order. Chotku wonders, how many distinct prefix-suffix concatenation is possible out there of string S.
So you know what to do.. Help Chotku!
Input
Input file contains several lines of text. Each line contains a string, S. End of file marks the end of input.
Output
Output one integer per string, denoting the number of distinct prefix-suffix concatenation of the string.
Constraints
-
Strings consist of lower-case letters only.
-
1 ≤ L ≤ 10000006
Sample Input |
Output for Sample Input |
abc |
8 |
Explanation:
For sample #1, the 3 prefixes are “a”, “ab”, “abc”
The 3 suffixes are “c”, “bc”, “abc”
And the 8 distinct concatenations are, “ac”, “abc”, “aabc”, “abbc”, “ababc”, “abcc”, “abcbc”, “abcabc”.