ZOJ-1163-The Staircases
作者:互联网
dp[i][j]表示i个砖头构成的最高台阶不高于j的楼梯数目
Accepted | 1163 | C++11 | 0 | 2280 |
#include "bits/stdc++.h" using namespace std; typedef long long LL; const int MAXN = 500 + 5; LL dp[MAXN][MAXN]; void init() { for (int i = 0; i < MAXN; i++) { dp[0][i] = 1; } for (int i = 1; i < MAXN; i++) { for (int j = 1; j <= i; j++) { dp[i][j] += dp[i][j - 1] + dp[i - j][j - 1]; } for (int j = i + 1; j < MAXN; j++) { dp[i][j] = dp[i][j - 1]; } } } int main() { init(); int n; while (scanf("%d", &n) && n) { // 题目要求至少两个台阶,所以不能包含n这个高度的台阶 printf("%lld\n", dp[n][n - 1]); } return 0; }
标签:std,1163,int,ZOJ,long,MAXN,Staircases,LL 来源: https://www.cnblogs.com/Angel-Demon/p/10341268.html