hdu 1723

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1723

思路:dp,不多说了,说多了都是泪啊。。。

View Code
 1 #include<iostream>
 2 const int N=77;
 3 using namespace std;
 4 
 5 int main(){
 6     int n,m;
 7     while(~scanf("%d%d",&n,&m)){
 8         if(n==0&&m==0)break;
 9         int dp[N];
10         memset(dp,0,sizeof(dp));
11         dp[1]=1;
12         for(int i=1;i<=n;i++){
13             for(int j=1;j<=m;j++){
14                 if(i+j>n)break;
15                 dp[i+j]+=dp[i];
16             }
17         }
18         printf("%d\n",dp[n]);
19     }
20     return 0;
21 }

 

 

posted @ 2013-04-03 22:14  ihge2k  阅读(181)  评论(0编辑  收藏  举报