using
System;
public
class
ValidStrings {
static
long
[, , ] dp =
new
long
[10, 10, 100005];
static
int
mod = (
int
)1e9 + 7;
static
long
CountValidString(
int
zeroCount,
int
oneCount,
int
K1,
int
K2,
int
n)
{
if
(n == 0)
return
1;
if
(dp[zeroCount, oneCount, n] != -1)
return
dp[zeroCount, oneCount, n];
long
res1 = 0, res2 = 0, res3 = 0;
for
(
int
i = 0; i <= 2; i++) {
if
(zeroCount < K1 && i == 0) {
res1 = CountValidString(zeroCount + 1, 0,
K1, K2, n - 1);
}
if
(oneCount < K2 && i == 1) {
res2 = CountValidString(
zeroCount, oneCount + 1, K1, K2, n - 1);
}
res3 = CountValidString(zeroCount, 0, K1, K2,
n - 1);
}
return
dp[zeroCount, oneCount, n]
= (res1 + res2 + res3) % mod;
}
public
static
void
Main(
string
[] args)
{
int
n = 1012, K1 = 3, K2 = 5;
for
(
int
i = 0; i < 10; i++) {
for
(
int
j = 0; j < 10; j++) {
for
(
int
k = 0; k < 100005; k++) {
dp[i, j, k] = -1;
}
}
}
Console.WriteLine(
CountValidString(0, 0, K1, K2, n));
}
}