滚动数组版
~~还是WA~~
```cpp
#include<cstdio>
#include<iostream>
using namespace std;
const int maxn = 1005;
const int maxm = 205;
const int maxk = 205;
typedef long long ll;
const ll mod = 1e9 + 7;
ll dp[2][maxm][maxk][2];
char a[maxn], b[maxm];
int main() {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
scanf("%s%s", a + 1, b + 1);
register int x, y;
dp[0][0][0][0] = dp[0][0][0][1] = 1;
for(int i = 1;i <= n;i++) {
for(int j = 1;j <= m;j++) {
for(int p = 1;p <= k;p++) {
x = i % 2, y = (x ^ 1);
dp[x][j][p][0] = dp[y][j][p][0] + dp[y][j][p][1];
if(a[i] == b[j]) {
dp[x][j][p][1] += dp[y][j - 1][p - 1][0];
dp[x][j][p][1] += dp[y][j - 1][p - 1][1];
dp[x][j][p][1] += dp[y][j - 1][p][1];
} else {
dp[x][j][p][1] = 0;
}
}
}
}
printf("%lld\n", dp[x][m][k][0] + dp[x][m][k][0]);
return 0;
}
```
by Str1n9 @ 2018-10-28 21:12:09