MODIfied POWER SET

0

0 votes
Problem

As we all know that power sets of any set are formed by taking i elements (where i is from 1 to n) and then random shuffling them like this power set of {1,2,3} are {EMPTY SET},{1},{2},{3},{1,2}{1,3}{2,3}{1,2,3} .

Now we have a MODIfied POWER SET which contains only those subsets which have consecutive elements from set and does not contains an empty set.Suppse in above example {1,2,3} number of MODIfied POWER SETS would be 6 we will eliminate {1,3} from power set since 1 and 3 are now consecutive numbers in the set(they are seperated by 2) & secondly by deleting empty set from it.Now you have knowledge of power set .Now,MANAN wants you to solve a simple problems stated as:_ Given a string now we have to form a SET(Lets make it clear again we have to form a SET) from this string.And output the number of MODIfied POWER SETs of that SET.

NOTE:- Please note that if the set if {1,3,2} then MODIfied Power sets will be {1},{3},{2},{1,3},{3,2},{1,3,2} as 1 and 2 are not consecutive elements from the set.

INPUT FORMAT:-

First Line of input contains an integer t denoting number of test cases. Each of the test case would contain a string containing numerals & alphabets.

OUTPUT FORMAT:-

Output for each test case is a single value denoting number of MODIfied POWER SETS.

Constraints:- 1<=t<=100 1<=|length of string|<=10^6

Sample Input
2
abcde
abc
Sample Output
15
6
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?