The Mook Jongaccepts:506submissions:1281Time limit:2000/1000 MS (java/others)Memory limit:65536/65536 K (java/others)Problem description
In order to keep fit, Zjiaq decided to practise martial arts through Mook Jong Piles. Zjiaq wanted to put Mook Jong piles in his own 1*n yard, which was paved with 1*1 tiles. Since Zjiaq is a compulsive disorder, he's going to put a Mook Jong pile
On a floor tile, because the Mook Jong pile hand is longer, so the floor tiles between the two Mook Jong piles must be greater than or equal to two, now Zjiaq want to know at least in the case of placing a Mook Jong pile, how many kinds of pendulum method.
Enter a description
Input has multiple sets of data, the first behavior of each group of data an integer n (1 < = n < = 60)
Output description
For each set of data output one row indicates the number of placement scenarios
Input sample
123456
Output sample
1235812
Test instructions: Chinese problem surface;
The main point: recursive processing to consider the current position POS can make the largest contribution (before the POS block brick according to the requirements of Mook Jong Piles have dp[pos] situation in the POS position placed a);
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 Long Longdp[ -];6 intN;7 intMain () {8 while(SCANF ("%d", &n)! =EOF) {9 Long Longsum=0;Ten for(intI=1; i<=n;i++) dp[i]=1; One for(intI=3; i<=n;i++) A for(intj=i-3; j>=1; j--) dp[i]+=Dp[j]; - for(intI=1; i<=n;i++) sum+=Dp[i]; -printf"%lld\n", sum); the } -}
HDU 5366 DP Recursion