URAL1017. Staircases

链接

简单递推

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<stdlib.h>
 6 using namespace std;
 7 #define LL long long
 8 LL dp[510][510];
 9 int main()
10 {
11     int i,j,n,g;
12     LL ans=0;
13     scanf("%d",&n);
14     for(i = 1; i <= n ;i++)
15     dp[i][i] = 1;
16     for(i = 1; i <= n ;i++)
17     {
18         for(j = 1 ; j < i ; j++)
19         {
20             for(g = 1 ; g < j ; g++)
21             dp[i][j]+=dp[i-j][g];
22         }
23     }
24     for(i = 1; i < n ;i++)
25     ans+=dp[n][i];
26     printf("%lld\n",ans);
27     return 0;
28 }
View Code

 

posted @ 2013-09-03 20:29  _雨  阅读(226)  评论(0编辑  收藏  举报