HDU 2084 Number Tower

Source: Internet
Author: User

Number of towers

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 32087 Accepted Submission (s): 19162


Problem description When it comes to DP algorithms, a classic example is the tower problem, which is described in this way:

As shown in the following tower, required to go from the top floor to the bottom, if each step can only go to adjacent nodes, then the number of nodes through the sum of the maximum is how much?

Already told you, this is a DP problem, can you AC?

Input data first includes an integer c, which indicates the number of test instances, the first line of each test instance is an integer N (1 <= N <= 100), which represents the height of the tower, followed by the number of columns in N rows, where I is an integer in the line I, and all integers are in the interval [ 0,99] inside.

Output for each test instance, the outputs may be the largest and one row per instance output.

Sample Input1573 88 1 0 2 7 4 44 5 2 6 5

Sample Output30

Source 2006/1/15 ACM Program Design Final Exam

Recommendlcy
1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 6 Const intmaxn= the;7 intA[MAXN][MAXN];8 intD[MAXN][MAXN];9 Ten intMain () One { A     intT,n; -scanf"%d",&t); -      while(t--) the     { -scanf"%d",&n); -          for(intI=1; i<n;i++) -              for(intj=1; j<n;j++) +d[i][j]=0; -          for(intI=1; i<=n;i++) +              for(intj=1; j<=i;j++) Ascanf"%d",&a[i][j]); at          for(intI=1; i<=n;i++) d[n][i]=A[n][i]; -          for(inti=n-1; i>=1; i--) -              for(intj=1; j<=i;j++) -D[i][j]=a[i][j]+max (d[i+1][j],d[i+1][j+1]); -printf"%d\n", d[1][1]); -     } in}

HDU 2084 Number Tower

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.