[2026 CCPC_NC_I C] 简单字符串题
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
我们可以定义 表示两个字符串 相连接,例如 ,,则 。
并递归地定义 , ( 且为正整数)。例如 ,则 。
现给定一个长度为 的字符串 ,给定常数 ,求 的方案数,其中 为任意非空字符串, 为任意正整数。
两种方案不同当且仅当 中有至少一个字符串或数字不同。
答案要对 取模。
Format
Input
第一行两个整数 (, ),第二行一个字符串 ,意义见题目描述。 仅由英文小写字母构成。
Output
输出一行一个整数表示答案。
Samples
5 1
aabcc
11
6 2
aaaaaa
19
8 1
aabaabcd
27
Note
对于第一组样例,有以下 种方案:
- $A=\texttt{a},\ B_1=\texttt{a},\ C=\texttt{bcc},\ i=1,\ j=1$
- $A=\texttt{a},\ B_1=\texttt{ab},\ C=\texttt{cc},\ i=1,\ j=1$
- $A=\texttt{a},\ B_1=\texttt{abc},\ C=\texttt{c},\ i=1,\ j=1$
- $A=\texttt{aa},\ B_1=\texttt{b},\ C=\texttt{cc},\ i=1,\ j=1$
- $A=\texttt{aa},\ B_1=\texttt{bc},\ C=\texttt{c},\ i=1,\ j=1$
- $A=\texttt{aab},\ B_1=\texttt{c},\ C=\texttt{c},\ i=1,\ j=1$
- $A=\texttt{a},\ B_1=\texttt{ab},\ C=\texttt{c},\ i=1,\ j=2$
- $A=\texttt{a},\ B_1=\texttt{b},\ C=\texttt{c},\ i=2,\ j=2$
- $A=\texttt{aa},\ B_1=\texttt{b},\ C=\texttt{c},\ i=1,\ j=2$
- $A=\texttt{a},\ B_1=\texttt{b},\ C=\texttt{cc},\ i=2,\ j=1$
- $A=\texttt{a},\ B_1=\texttt{bc},\ C=\texttt{c},\ i=2,\ j=1$
2026CCPC南昌邀请赛暨江西省赛(unofficial)
- Status
- Done
- Rule
- XCPC
- Problem
- 13
- Start at
- 2026-9-30 13:30
- End at
- 2026-9-30 17:30
- Duration
- 4 hour(s)
- Host
- Partic.
- 2