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.
20 lines
395 B
20 lines
395 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N = 5010;
|
|
int f[N];
|
|
int n, k;
|
|
int main() {
|
|
cin >> n >> k;
|
|
if (k == 1) {
|
|
cout << 1 << endl;
|
|
exit(0);
|
|
}
|
|
f[1] = 1;
|
|
f[2] = 2;
|
|
|
|
for (int i = 3; i <= n; i++)
|
|
for (int j = max(i - k, 1); j <= max(1, i - 1); j++)
|
|
f[i] += f[j];
|
|
cout << f[n] << endl;
|
|
return 0;
|
|
} |