#abc214f. F - Substrings
F - Substrings
Score : points
问题描述
给定一个字符串 。Takahashi 将按照以下方式从这个字符串中创建一个新的字符串 。
- 首先,在字符串 中标记一个或多个字符。注意,相邻的两个字符不能都被标记。
- 然后,删除所有未被标记的字符。
- 最后,将剩余的字符串定义为 。在此过程中,禁止改变字符的顺序。
有多少种可能得到的字符串 ?请计算这些字符串的数量对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
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 .
Sample Input 1
abc
Sample Output 1
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.
Sample Input 2
aa
Sample Output 2
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.
Sample Input 3
acba
Sample Output 3
6
There are six strings that can be obtained as : a
, b
, c
, aa
, ab
, and ca
.
Sample Input 4
chokudai
Sample Output 4
54
update @ 2024/3/10 09:31:55