This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
usingnamespacestd;
constintN=5010;
intf[N];// DP结果数组 f[i]含义:第i层台阶共有多少种到达的方法数
intn,k;
/*
4 2
5
*/
intmain(){
cin>>n>>k;
// 特判K=1
if(k==1){
cout<<1<<endl;
exit(0);
}
// 初始化 K>=2
f[1]=1;
f[2]=2;
// 状态转移方程
for(inti=3;i<=n;i++)
for(intj=max(i-k,1);j<=max(1,i-1);j++)
f[i]+=f[j];
// for (int i = 1; i <= n; i++) cout << f[i] << " ";