You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
589 B

#include <bits/stdc++.h>
using namespace std;
const int N = 100010, mod = 5000011;
int n, k;
int f[N];
// PASS 8/12 其它的TLE
int main() {
cin >> n >> k;
f[0] = 1; // 此处设置一个边界f[0]表示只有0没有1的边界情况
for (int i = 1; i <= n; i++) {
if (i - k - 1 < 0)
f[i] = f[0];
else
for (int j = 0; j <= i - k - 1; j++)
f[i] = (f[i] + f[j]) % mod;
}
int res = 0;
for (int i = 0; i <= n; i++) res = (res + f[i]) % mod;
printf("%d\n", res);
return 0;
}