#P2679. [NOIP 2015 提高组] 子串

    ID: 1700 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>字符串动态规划,dp2015NOIp 提高组O2优化枚举,暴力

[NOIP 2015 提高组] 子串

Description

There are two strings AA and BB consisting only of lowercase English letters.

We will select kk pairwise non-overlapping, non-empty substrings from string AA, then concatenate these kk substrings in the order they appear in AA to obtain a new string. How many ways are there to make this new string equal to string BB?

Note: Different selection positions are considered different ways.

Input Format

The first line contains three positive integers n,m,kn, m, k, representing the length of string AA, the length of string BB, and the kk mentioned in the problem statement, respectively. Each pair of integers is separated by a single space.

The second line contains a string of length nn, which is string AA.

The third line contains a string of length mm, which is string BB.

Output Format

Output a single integer, the number of required ways.

Since the answer may be large, output the result modulo 10000000071000000007.

6 3 1 
aabaab 
aab
2
6 3 2 
aabaab 
aab
7
6 3 3 
aabaab 
aab
7

Hint

Sample Explanation

All valid ways are as follows (the underlined parts indicate the selected substrings):

Sample 1: aabaab,aabaab\texttt{\underline{aab}\,aab,aab\,\underline{aab}}.

Sample 2: $\texttt{\underline{a}\,\underline{ab}\,aab,\underline{a}\,aba\,\underline{ab},a\,\underline{a}\,ba\,\underline{ab},aab\,\underline{a}\,\underline{ab},\underline{aa}\,\underline{b}\,aab,\underline{aa}\,baa\,\underline{b},aab\,\underline{aa}\,\underline{b}}$.

Sample 3: $\texttt{\underline{a}\,\underline{a}\,\underline{b}\,aab,\underline{a}\,\underline{a}\,baa\,\underline{b},\underline{a}\,ab\,\underline{a}\,a\,\underline{b},\underline{a}\,aba\,\underline{a}\,\underline{b},a\,\underline{a}\,b\,\underline{a}\,a\,\underline{b},a\,\underline{a}\,ba\,\underline{a}\,\underline{b},aab\,\underline{a}\,\underline{a}\,\underline{b}}$.

Constraints

For testdata 1: 1n500,1m50,k=11 \le n \le 500, 1 \le m \le 50, k = 1;

For testdata 2 to 3: 1n500,1m50,k=21 \le n \le 500, 1 \le m \le 50, k = 2;

For testdata 4 to 5: 1n500,1m50,k=m1 \le n \le 500, 1 \le m \le 50, k = m;

For testdata 1 to 7: 1n500,1m50,1km1 \le n \le 500, 1 \le m \le 50, 1 \le k \le m;

For testdata 1 to 9: 1n1000,1m100,1km1 \le n \le 1000, 1 \le m \le 100, 1 \le k \le m;

For all 10 testdata sets: 1n1000,1m200,1km1 \le n \le 1000, 1 \le m \le 200, 1 \le k \le m.

Translated by ChatGPT 5