#d2563. 子串分值和
子串分值和
Sum of Substring Values
Problem Description
For a string , we define as the number of distinct characters that appear in . For example , , .
Now you are given a string (suppose its length is ). Please compute $\sum\limits_{i=0}^{len-1} \sum\limits_{j=i}^{len-1} f(S[i:j])$.
Input Format
One line containing a string consisting of lowercase letters.
Output Format
Output one integer, the answer.
Sample Input
ababc
Sample Output
28
Constraints
For all data, the string length , and string indices run from to .