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

  1. 0 0 4 0 0 1
  2. 7 5 1 0 0 0
  3. 0 0 0 0 0 0

Sample Output

  1. 2
  2. 1
  3.  
  4. 题目大意
    就是给你六个数字,从前往后依次代表,i*i类型的箱子,不考虑高度,问你给你最少多少个6*6的箱子
    首先意识到,456单独占一个箱子,3*3的四个占一个箱子,先根据3456求出一个大概的数量
    之后2就填充34占用的箱子空下来的空间,1就占用其他空间。
  5.  
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <algorithm>
  5. #include <iostream>
  6. using namespace std;
  7. int dir[4]={0,5,3,1};
  8. int main()
  9. {
  10. int a[10];
  11. while(1)
  12. {
  13. int sum=0,ans=0;
  14. for(int i=1;i<=6;i++)
  15. {
  16. scanf("%d",&a[i]);
  17. sum+=a[i];
  18. }
  19. if(sum==0) break;
  20. ans=(a[3]+3)/4+a[4]+a[5]+a[6];
  21. int cnt_2=a[4]*5+dir[a[3]%4];
  22. if(a[2]>cnt_2)
  23. {
  24. ans+=(8+a[2]-cnt_2)/9;
  25. }
  26. int cnt_1=ans*36-a[3]*9-a[4]*16-a[5]*25-a[6]*36-a[2]*4;
  27. if(a[1]>cnt_1)
  28. {
  29. ans+=(35+a[1]-cnt_1)/36;
  30. }
  31. printf("%d\n",ans);
  32. }
  33. return 0;
  34. }

  

  1.  

A - Packets 贪心的更多相关文章

  1. UVA 311 Packets 贪心+模拟

    题意:有6种箱子,1x1 2x2 3x3 4x4 5x5 6x6,已知每种箱子的数量,要用6x6的箱子把全部箱子都装进去,问需要几个. 一开始以为能箱子套箱子,原来不是... 装箱规则:可以把箱子都看 ...

  2. poi 1017 Packets 贪心+模拟

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 48349   Accepted: 16392 Descrip ...

  3. Poj 1017 Packets(贪心策略)

    一.题目大意: 一个工厂生产的产品用正方形的包裹打包,包裹有相同的高度h和1*1, 2*2, 3*3, 4*4, 5*5, 6*6的尺寸.这些产品经常以产品同样的高度h和6*6的尺寸包袱包装起来运送给 ...

  4. POJ 1O17 Packets [贪心]

    Packets Description A factory produces products packed in square packets of the same height h and of ...

  5. poj 1017 Packets 贪心

    题意:所有货物的高度一样,且其底面积只有六种,分别为1*1 2*2 3*3 4*4 5*5 6*6的,货物的个数依次为p1,p2,p3,p4,p5,p6, 包裹的高度与货物一样,且底面积就为6*6,然 ...

  6. poj 1017 Packets 裸贪心

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43189   Accepted: 14550 Descrip ...

  7. uva311 - Packets(贪心)

    题目:311 - Packets 题目大意:给出1*1, 2*2,3 *3, 4*4, 5*5, 6*6的箱子的个数,如今有若干个6*6的箱子,问最少用多少个箱子能够将给定的箱子都装进去. 解题思路: ...

  8. POJ 1017 Packets【贪心】

    POJ 1017 题意: 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为 1*1, 2*2, 3*3, 4*4, 5*5, 6*6.  这些产品通常 ...

  9. poj-1017 Packets (贪心)

    http://poj.org/problem?id=1017 工厂生产高度都为h,长和宽分别是1×1 2×2 3×3 4×4 5×5 6×6的6种规格的方形物品,交给顾客的时候需要包装,包装盒长宽高都 ...

随机推荐

  1. 《Office 365开发入门指南》上市说明和读者服务

    写在最开始的话 拙作<Office 365开发入门指南>上周开始已经正式在各大书店.在线商城上市,欢迎对Office 365的开发.生态感兴趣的开发者.项目经理.产品经理参考本书,全面了解 ...

  2. SET XACT_ABORT ON是什么?

    避免自己遗忘,在这里做个笔记: SET XACT_ABORT ON:强制事务回滚,如果不加这句的话事务有可能回滚失败.

  3. 【Java每日一题】20170227

    20170224问题解析请点击今日问题下方的“[Java每日一题]20170227”查看(问题解析在公众号首发,公众号ID:weknow619) package Feb2017; import jav ...

  4. python文件

    目录 1. 文件的概念 1.1 文件的概念和作用 1.2 文件的存储方式 2. 文件的基本操作 2.1 操作文件的套路 2.2 操作文件的函数/方法 2.3 read 方法 -- 读取文件 2.4 打 ...

  5. 空间、域名与IP之间的关系?

    空间说白了就是服务器里面你可以使用的一个地方,在这里你可以放置数据和程序.最常用的就是放置您的网站程序和相关的所有文档和图片文件等等.这个放置你的网站文件的空间所在的服务器会有一个电信部门分配的固定编 ...

  6. angular raido checkbox select取值

    radio {{modelName}} <div class="radio disIB"> <label class="i-checks"&g ...

  7. [HTML/CSS]下拉菜单

    原理:先让下拉菜单隐藏,鼠标移到的时候在显示出来 1>display 无动画效果,图片是秒出 2>opacity 有动画效果,我这里是1S出现,推荐配合绝对定位使用

  8. CSS gradient渐变之webkit核心浏览器下的使用以及实例

    一.关于渐变 渐变是一种应用于平面的视觉效果,可以从一种颜色逐渐地转变成另外一种颜色,故可以创建类似于彩虹的效果渐变可以应用在任何可以使用图片的地方.例如,您可以指定一个这么一个渐变:顶部的颜色是红色 ...

  9. JS里面的装箱和拆箱操作

    平日工作里,我想各位少侠对下面的用法都不陌生吧 var s1 = "abc"; var s2 = s1.indexOf("a") 还有例如什么indexOf() ...

  10. [新特性]PeopleTools8.54+:PeopleSoft Application Engine新特性

    PeopleTools 8.54 的Application Engine 已经被更新,特别是在AE跟踪设置中有了更多的选项,本文将帮助您了解8.54的新AE特性以及如何使用这些特性. AE trace ...