atcoder#DWACON5THPRELIMSC. k-DMC
k-DMC
Score : points
Problem Statement
In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.
Given a string of length and an integer , he defines the k-DMC number of as the number of triples of integers that satisfy the following conditions:
- =
D
- =
M
- =
C
Here is the -th character of the string . Indexing is zero-based, that is, holds.
For a string and integers , calculate the -DMC number of for each .
Constraints
- consists of uppercase English letters
- All numbers given in input are integers
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the -DMC number of the string .
18
DWANGOMEDIACLUSTER
1
18
1
satisfies the conditions. Strangely, Dwango Media Cluster does not have so much DMC-ness by his definition.
18
DDDDDDMMMMMCCCCCCC
1
18
210
The number of triples can be calculated as .
54
DIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED
3
20 30 40
0
1
2
satisfy the conditions except the last one, namely, . By the way, DWANGO is an acronym for "Dial-up Wide Area Network Gaming Operation".
30
DMCDMCDMCDMCDMCDMCDMCDMCDMCDMC
4
5 10 15 20
10
52
110
140