4599: Substrings Same as Prefix

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:0 通过:0

题目描述

We want to know how similar the content of a string is to its prefix. A string could gain a score of k when there is a non-prefix substring of length k that is the same as its prefix. Find the total score for a string.

输入格式

There are 20 test cases. Each case contains a string of English letters with length n.

1 ≤ n ≤ 105

输出格式

Each case one line, the score of the string.

输入样例 复制

abcabc
aaaa

输出样例 复制

6
10

数据范围与提示

For the first case, “a”, “ab”, “abc” are non-prefix substrings same as prefix and the score is 1+2+3=6.

For the second case, 3 “a”s, 2 “aa”s and 1 “aaa” are non-prefix substrings same as prefix. Then the score is 3+4+3=10.

分类标签