#P1393. Mivik 的标题
Mivik 的标题
Description
Since Mivik wrote the book by randomly hitting keys on the keyboard, he plans to do the same for the book title. Mivik's keyboard has different keys, corresponding to different characters. Mivik decides to hit keys on this keyboard uniformly at random times to produce the title. However, for some reason, Mivik wants the title to contain a person's name . Therefore, Mivik asks you: what is the probability that the randomly typed title contains this name.
Also, Mivik does not like weird-looking decimals, so you only need to output this probability modulo .
Input Format
The first line contains three integers , , , where is the length of this name.
The second line gives integers , representing this name.
Output Format
Output one integer in one line, representing the probability modulo .
3 2 2
1 1
623902721
6 3 4
1 2 3 2
480636170
Hint
Sample Explanation
In sample 1, for convenience, we define the two keys on the keyboard as a and b. Then all strings of length 3 are aaa, aab, aba, abb, baa, bab, bba, bbb, a total of 8 strings. Among them, the ones that contain the given name aa are aaa, aab, baa, which is 3 strings, so the probability is . Taking it modulo gives 623902721.
Constraints
For all testdata, , , .
Subtask 1 (5 pts): .
Subtask 2 (20 pts): .
Subtask 3 (30 pts): .
Subtask 3 (45 pts): no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号