POJ 1017 Packets

Source: Internet
Author: User

Test instructions: There are some 1x1, 2x2, 3x3, 4x4, 5x5, 6x6 cargo, each cargo height is H, the goods are packed, each package can be loaded 6x6xh, ask at least a few parcels.

Solution: 6x6 directly into the 5x5 space can be filled with 1x1, 4x4 can be used 2x2 and 1x1 fill, 3x3 Four can be composed of a package, a multi-and 2x2 and 1x1 combination, 2x2 9 composed of a parcel, multi and 1x1 combination, 1x 1 of the 36 to form a package, in order to simulate the above Otz do not know how to think ... Write a lot of bugs to

Code:

#include <stdio.h> #include <iostream> #include <algorithm> #include <string> #include < string.h> #include <math.h> #include <limits.h> #include <time.h> #include <stdlib.h># include<map> #include <queue> #include <set> #include <stack> #include <vector> #define LL    Long longusing namespace Std;int main () {int A, B, C, D, E, F; while (~SCANF ("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) &&! ( A = = 0 && b = 0 && c = 0 && D = = 0 && e = 0 && f = 0) {int ans = 0        ;        Ans + = f;        Ans + = e;        int TMP = one * e;        A = max (0, a-tmp);        ans + = D;        TMP = 5 * D; if (b < tmp) {tmp-= b;//because these two sentences have been reversed for a half-day bug ...        The IQ of the clumsy B = 0;            } else {b = tmp;        TMP = 0;        } a = max (0, a-tmp * 4);        Ans + = C/4;        C%= 4;        TMP = 0; if (c)       {ans++;            TMP = 36-c * 9;            int ttmp = 0;            if (c = = 1) ttmp = 5;            else if (c = = 2) ttmp = 3;            else ttmp = 1;            TMP-= ttmp * 4;                if (b < ttmp) {ttmp-= b;            b = 0;                } else {b-= ttmp;            ttmp = 0;        } a = max (0, a-ttmp * 4-tmp);        } ans + = B/9;        b%= 9;            if (b) {ans++;        A = max (0, a-36 + 4 * b);        } ans + = A/36;        A%= 36;        if (a) ans++;    printf ("%d\n", ans); } return 0;}

  

POJ 1017 Packets

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.