atcoder#ABC214F. [ABC214F] Substrings
[ABC214F] Substrings
Score : points
Problem Statement
Given is a string . From this string, Takahashi will make a new string as follows.
- First, mark one or more characters in . Here, no two marked characters should be adjacent.
- Next, delete all unmarked characters.
- Finally, let be the remaining string. Here, it is forbidden to change the order of the characters.
How many strings are there that can be obtained as ? Find the count modulo .
Constraints
- is a string of length between and (inclusive) consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print the number of different strings that can be obtained as , modulo .
abc
4
There are four strings that can be obtained as : a
, b
, c
, and ac
.
Marking the first character of yields a
;
marking the second character of yields b
;
marking the third character of yields c
;
marking the first and third characters of yields ac
.
Note that it is forbidden to, for example, mark both the first and second characters.
aa
1
There is just one string that can be obtained as , which is a
.
Note that marking different positions may result in the same string.
acba
6
There are six strings that can be obtained as : a
, b
, c
, aa
, ab
, and ca
.
chokudai
54