Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

How Hasinur Met His Girlfriends

By Nobel_ruettt · Limits 1s, 512 MB

Hasinur’s love interest is always curious about different strings and their properties. He wants to impress her and needs your help.

You will be given several strings and you will have to find the number of distinct sub-strings of that string.

Input

Input will start with an integer TT (1T1001 ≤ T ≤ 100), number of test cases. In each test case a string will be given. The length of each string will be at most 50. A string will contain only lowercase Latin letters ('a' - 'z').

Output

For each test case, output an integer in a single line—the answer of the corresponding test case according to the problem statement.

Sample

InputOutput
2
aaaa
aaa
4
3

A substring is a contiguous sequence of characters within a string. For example; the sub-strings of the string "abc" are "a", "ab", "abc", "b", "bc" and "c".

Discussion

Statistics


71% Solution Ratio

skmonirEarliest, Nov '18

Alamin_justFastest, 0.0s

Alamin_justLightest, 131 kB

touhidurrrShortest, 105B

Submit

Login to submit

Editorial

Constraints are flexible. So we can do bruteforce for this problem. We can generate all the substrin...

Toph uses cookies. By continuing you agree to our Cookie Policy.