spoj694 Distinct Substrings

来源:互联网 发布:网站防sql注入 编辑:程序博客网 时间:2024/06/06 00:42

SPOJ Problem Set (classical)

694. Distinct Substrings

Problem code: DISUBSTR

 

Given a string, we need to find the total number of its distinct substrings.

Input

T- number of test cases. T<=20;
Each test case consists of one string, whose length is <= 1000

Output

For each test case output one number saying the number of distinct substrings.

Example

Sample Input:
2
CCCCC
ABABA

Sample Output:
5
9

Explanation for the testcase with string ABABA: 
len=1 : A,B
len=2 : AB,BA
len=3 : ABA,BAB
len=4 : ABAB,BABA
len=5 : ABABA
Thus, total number of distinct substrings is 9.


Added by:PrasannaDate:2006-01-13Time limit:1sSource limit:50000BLanguages:All except: PERL 6Resource:

ByteCode '06

 

 

 

 

 

 

 

 

 

 

原创粉丝点击