atcoder#ABC215E. [ABC215E] Chain Contestant
[ABC215E] Chain Contestant
Score : points
Problem Statement
AtCoder in another world holds types of contests called AAC, ..., AJC. There will be contests from now on. The types of these contests are given to you as a string : if the -th character of is , the -th contest will be AC. AtCoDeer will choose and participate in one or more contests from the so that the following condition is satisfied.
- In the sequence of contests he will participate in, the contests of the same type are consecutive.- Formally, when AtCoDeer participates in contests and the -th of them is of type , for every triple of integers such that , must hold if .
Find the number of ways for AtCoDeer to choose contests to participate in, modulo . Two ways to choose contests are considered different when there is a contest such that AtCoDeer participates in in one way but not in the other.
Constraints
- consists of uppercase English letters from
A
throughJ
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
4
BGBH
13
For example, participating in the -st and -rd contests is valid, and so is participating in the -nd and -th contests. On the other hand, participating in the -st, -nd, -rd, and -th contests is invalid, since the participations in ABCs are not consecutive, violating the condition for the triple . Additionally, it is not allowed to participate in zero contests. In total, there are valid ways to participate in some contests.
100
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBIEIJEIJIJCGCCFGIEBIHFCGFBFAEJIEJAJJHHEBBBJJJGJJJCCCBAAADCEHIIFEHHBGF
330219020
Be sure to find the count modulo .