本题是一道很简单的递归题,建立一个数组f[],找出f[i]与k之间的关系即可
#include <bits/stdc++.h>
//#define LL long long
using namespace std;
//typedef long long LL;
const int N = 1e5 + 10;
int f[N];
int n, k;
int main()
{
cin >> n >> k;
f[0] = 1;
f[1] = 1;
for (int i = 2; i <= n; ++i)
{
for (int j = 1; j <= k; ++j)
{
if (i - j < 0)
break;
f[i] = (f[i] + f[i - j]) % 100003;
}
}
cout << f[n] << endl;
return 0;
}