Poj 1017 packets (accumulation)

Source: Internet
Author: User

[Description]: This is a blog of others. It has a clear description of the question and a solution. It can be used to solve this problem!

[Analysis]: greedy? Simulation? See the code

// 216 K 16 Ms # include <iostream> using namespace STD; int main () {int ans, A, B, C, D, E, F, two, one; // two indicates the number of 2*2, and one indicates the number of 1*1. Int U [4] = {0, 5, 3, 1}; while (1) {CIN> A> B> C> D> E> F; if (A = 0 & B = 0 & C = 0 & D = 0 & E = 0 & F = 0) break; ans = F + E + D + (C + 3)/4; // here (C + 3)/4 is equal to C divided by 4 and rounded up. Of course, we can also replace it with the ceiling Function two = 5 * D + U [C % 4]; If (B> Two) ans + = (B-two + 8) /9; // The method here is the same as (C + 3)/4, which is rounded up; one = 36 * ANS-36 * F-25 * E-16 * D-9 * C-4 * B; // The number of packages currently in use can be filled with 1*1! If (A> one) ans + = (A-one + 35)/36; // The same method is used. Cout <ans <Endl;} return 0 ;}


Poj 1017 packets (accumulation)

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.