JOIN
Get Time

   Problem Statement  

 Problem Statement for SquareScoresDiv2

Problem Statement

    

A substring of a string is a contiguous sequence of characters from the string. For example, each of the strings "ab", "bcd", and "e" is a substring of "abcde". On the other hand, "cba", "ace", and "f" are not substrings of "abcde".

The score of a string S is the number of ways in which we can select a non-empty substring of S such that all characters in the substring are the same. If two substrings consist of the same letters but occur at different places in S, they are still considered different. For example, the score of "aaaba" is 8: there are four occurrences of the substring "a", two occurrences of "aa", one occurrence of "aaa", and one of "b".

On her birthday, Maki got a String s from her friend Niko as a present. Calculate and return its score.

 

Definition

    
Class:SquareScoresDiv2
Method:getscore
Parameters:String
Returns:int
Method signature:int getscore(String s)
(be sure your method is public)
    
 

Constraints

-The length of s will be between 1 and 100, inclusive.
-Each character in s will be a lowercase letter ('a'-'z').
 

Examples

0)
    
"aaaba"
Returns: 8
The example explained above.
1)
    
"zzzxxzz"
Returns: 12
2)
    
"abcdefghijklmnopqrstuvwxyz"
Returns: 26
3)
    
"p"
Returns: 1
4)
    
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Returns: 5050
All substrings satisfy the condition.

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
       Single Round Match 654 Round 1 - Division II, Level One