zoukankan      html  css  js  c++  java
  • POJ

    Packets
    Time Limit: 1000MS   Memory Limit: 10000K
    Total Submissions: 59725   Accepted: 20273

    Description

    A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcels of the same height h as the products have and of the size 6*6. Because of the expenses it is the interest of the factory as well as of the customer to minimize the number of parcels necessary to deliver the ordered products from the factory to the customer. A good program solving the problem of finding the minimal number of parcels necessary to deliver the given products according to an order would save a lot of money. You are asked to make such a program.

    Input

    The input file consists of several lines specifying orders. Each line specifies one order. Orders are described by six integers separated by one space representing successively the number of packets of individual size from the smallest size 1*1 to the biggest size 6*6. The end of the input file is indicated by the line containing six zeros.

    Output

    The output file contains one line for each line in the input file. This line contains the minimal number of parcels into which the order from the corresponding line of the input file can be packed. There is no line in the output file corresponding to the last ``null'' line of the input file.

    Sample Input

    0 0 4 0 0 1 
    7 5 1 0 0 0 
    0 0 0 0 0 0 

    Sample Output

    2 
    1 

    http://poj.org/problem?id=1017

    题意:给你一些体积大小为1x1,2x2,3x3,4x4,5x5,6x6的方块,需要你装6x6的盒子里面,求最少需要的盒子

    从6x6的方块开始装,然后一个5x5的方块与11个1x1的方块装一个箱子,4x4的方块与5个2x2的方块或者x个1x1的方块装一个箱子

    依次贪心,最后可得公式所需最少的盒子为 ans=f+e+d+(c+3)/4+cnt2+cnt1个;

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    using namespace std;
    int a,b,c,d,e,f;
    
    int main()
    {
        while(cin>>a>>b>>c>>d>>e>>f){
            if(!a&&!b&&!c&&!d&&!e&&!f) break;
            int ans=f+e+d+(c+3)/4;
            int cnt2=0;
            cnt2+=5*d;
            if(c%4==3){
                cnt2+=1;
            }else if(c%4==2){
                cnt2+=3;
            }else if(c%4==1){
                cnt2+=5;
            }
            if(cnt2<b){
                ans+=(((b-cnt2)+8)/9);
            }
            int cnt1;
            cnt1=36*ans-36*f-25*e-16*d-9*c-4*b;
            if(cnt1<a){
                ans+=((a-cnt1)+35)/36;
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
    View Code
    每一个不曾刷题的日子 都是对生命的辜负 从弱小到强大,需要一段时间的沉淀,就是现在了 ~buerdepepeqi
  • 相关阅读:
    发现个atan2的正确使用方式
    Forward+ Shading架构
    fatal: unable to connect to gitee.com: gitee.com[0: 180.97.125.228]: errno=Unknown error 解决方案
    HDFS HA(高可用性)集群规划
    如何使用RTP引擎对语音编码进行转码
    关于 Angular 应用 tsconfig.json 中的 target 属性
    浅谈 Orbeon form builder 的权限控制
    关于 Angular 应用 tsconfig.json 中的 lib 属性
    orbeon form 通过 url 的方式同第三方应用集成的开发明细
    orbeon form 的配置介绍
  • 原文地址:https://www.cnblogs.com/buerdepepeqi/p/8727940.html
Copyright © 2011-2022 走看看