Problem E
Repeated Substrings

String analysis often arises in applications from biology and chemistry, such as the study of DNA and protein molecules. One interesting problem is to find how many substrings are repeated (at least twice) in a long string.
In this problem, you will write a program to find the total
number of repeated substrings in a string of at most
Input
The input consists of at most 10 cases. The first line
contains a positive integer, specifying the number of cases to
follow. Each of the following line contains a nonempty string
of up to
Output
For each line of input, output one line containing the number of unique substrings that are repeated. You may assume that the correct answer fits in a signed 32-bit integer.
Sample Input 1 | Sample Output 1 |
---|---|
3 aabaab aaaaa AaAaA |
5 4 5 |