#abc246f. F - typewriter
F - typewriter
Score : points
问题陈述
我们有一个包含 行的打字机。从上到下第 行的按键可以输入字符串 中的字符。
现在让我们使用这个键盘按照以下方式输入一个字符串。
- 首先,选择一个整数 。
- 然后,从一个空字符串开始,仅使用从顶部数起第 行的按键输入一个长度恰好为 的字符串。
有多少个长度为 的字符串可以通过这种方式输入?由于答案可能非常大,请输出结果对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a typewriter with rows. The keys in the -th row from the top can type the characters in a string .
Let us use this keyboard to enter a string, as follows.
- First, choose an integer .
- Then, start with an empty string and only use the keys in the -th row from the top to enter a string of length exactly .
How many strings of length can be entered in this way? Since the answer can be enormous, print it modulo .
Constraints
- and are integers.
- is a (not necessarily contiguous) non-empty subsequence of
abcdefghijklmnopqrstuvwxyz
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 2
ab
ac
Sample Output 1
7
We can enter seven strings: aa
, ab
, ac
, ba
, bb
, ca
, cc
.
Sample Input 2
4 3
abcdefg
hijklmnop
qrstuv
wxyz
Sample Output 2
1352
Sample Input 3
5 1000000000
abc
acde
cefg
abcfh
dghi
Sample Output 3
346462871
Be sure to print the answer modulo .
update @ 2024/3/10 10:33:54