bzoj 3398: [Usaco2009 Feb]Bullcow 牡牛和牝牛【dp】
设f[i]为i为牡牛的方案数,f[0]=1,s为f的前缀和,f[i]=s[max(i-k-1,0)]
#include<iostream>
#include<cstdio>
using namespace std;
const int N=100005,mod=5000011;
int n,m,f[N],s[N];
int main()
{
scanf("%d%d",&n,&m);
f[0]=s[0]=1;
for(int i=1;i<=n;i++)
{
f[i]=s[max(i-m-1,0)];
s[i]=(s[i-1]+f[i])%mod;
}
printf("%d\n",s[n]);
return 0;
}