首页 > 代码库 > hdu 1723 Distribute Message 递推

hdu 1723 Distribute Message 递推

 

#include <cstdio>#include <cstring>using namespace std;int dp[50];int main(){    int n,m;    while(1)    {        scanf("%d%d",&n,&m);        if(n==0&&m==0) break;        int i,j;        memset(dp,0,sizeof(dp));        dp[1]=1;        for(i=2;i<=n;i++)            for(j=i-m;j<i;j++)                if(j>0)                    dp[i]+=dp[j];        printf("%d\n",dp[n]);    }    return 0;}