Substrings | 프로그래밍의 벗 PivotOJ
PivotOJ

Substrings

시간 제한: 1000ms메모리 제한: 128MB출처: CCC 2003 SeniorBOJ 6908

문제

How many distinct substrings does a given string SS have?

For example, if S=S = abc, SS has 77 distinct substrings: , a, b, c, ab, bc, abc. Note that the empty string and SS itself are considered substrings of SS.

On the other hand, if S=S = aaa. SS has only 44 distinct substrings: , a, aa, aaa.

입력

The first line of the input file contains NN, the number of test cases. For each test case, a line follows giving SS, a string of from 11 to 50005000 alphanumeric characters.

출력

Your output consists of one line per case, giving the number of distinct substrings of SS.

예제

예제 1

입력
2
abc
aaa
출력
7
4
코드를 제출하려면 로그인하세요.