Canadian Computing Competition: 2003 Stage 1, Senior #4
How many distinct substrings does a given string have?
For example, if
abc, has distinct substrings:
abc. Note that the empty string and itself are considered substrings of .
On the other hand, if
aaa. has only distinct substrings:
The first line of the input file contains , the number of test cases. For each test case, a line follows giving , a string of from to alphanumeric characters.
Your output consists of one line per case, giving the number of distinct substrings of .
50% of test cases will have (the length of the string) where . For all cases, .
2 abc aaa
Output for Sample Input