HDU 5366 DP Recursion

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.