UVA 437 the Tower of Babylon Babel

Source: Internet
Author: User

give you a pile of squares of the length of the height, let you base a Babel, the tower higher the better. The requirement is that the length of the block below each block is greater than the length a above, and width B is greater than the width B above. (Hangzhou electric on that cottage monkey eat banana and the problem is the original problem)
Example 1 in the 10 20 30 can be such
the second layer: the first layer of the
: Ten
+ ______
Add = +
Line of thought see below code:

#include <iomanip>
using namespace std;
struct cube
    int a,b,c;
cube cu[91];
int dp[91];
bool cmp(const cube &a,const cube &b)
    return a.a*a.b>b.a*b.b;
int max(int a,int b)
    return a;
    return b;
int main()
    int n,a,b,c,ans,k=1;
        for(int i=1;i<=n*3;)
        for(int i=1;i<=3*n;i++)
            int tem=0;
            for(int j=1;j<i;j++)
        cout<<"Case "<<k++<<": maximum height = "<<ans<<endl;
    return 0;

Normal method can not be solved, generally is the dynamic planning problem ~ Consider Dp[i] for the first block for the top block to the maximum height, then there is Dp[i]=max (Dp[j]) +cu[i].c (j is less than I). Follow this line of thought, and you will send your answer clearly wrong. To associate with the longest increment sequence problem, the longest increment sequence problem is solved in the given sequence of sequences. Therefore, the problem should also be considered in order, every time I block to find the time to ensure that dp[i] must be able to index to the maximum value before I, so as to be able to find at the top of the block I is the maximum value (do not believe that you use the first example to try). So you can use the A*b area of the idea, of course, you should also use the length of a and the length of B to double-judge the method, after the application of the above transfer equation on the line ~

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.