Topic links
Test instructions: give you a n, ask you to have a variety of ways to put the steps.
Requires that the following grid number is strictly greater than the number of squares above, the steps must be at least two layers and above (so the final output to 1)
There are steps to look backwards, upside down, the far right is the bottom, I ... The heart is extremely rush to collapse ...
That means we just enumerate the longest edge h on the far right, and then the rest is n-h, which is clearly calculated.
Initialize dp[0] = 1, because any n can be assumed to be a layer.
The code is as follows:
#include <cstdio> #include <cstring>typedef long long ll;int n;ll dp[505];int main () {memset (DP, 0, sizeof (DP) );DP [0] = 1;for (int j = 1; J <=; J + +) {for (int i =; i > 0; i--) {if (i >= j) dp[i] + = Dp[i-j];}} while (~SCANF ("%d", &n) && N) {printf ("%lld\n", dp[n]-1);} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
zoj1163 the staircases (basic DP)