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

  

												

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. ___Jquery多选框的取值及反显数据

    Jquery操作 ------------------------------------------------------ var arr = new Array(); $("input ...

  2. [angularjs] angularjs系列笔记(六)http

    读取服务器json数据,get方式 <body> <div ng-app="Home"> <div ng-controller="httpT ...

  3. mybatis_01简介

    1.1 MyBatis MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名 ...

  4. 让MySQL查询更加高效——对查询进行重构

    在优化有问题的查询时,目标应该是找到一个更优的方法获得实际需要的结果,而不是一定总是要求从MySQL获取一模一样的结果集 一个复杂查询还是多个简单查询 设计查询的时候一定需要考虑的问题就是,是否需要将 ...

  5. Java岗 面试考点精讲(基础篇02期)

    1. 两个对象的hashCode相同,则equals也一定为true,对吗? 不对,答案见下面的代码: @Override public int hashCode() { return 1; } 两个 ...

  6. 二进制安装 kubernetes 1.12(三) - 部署 Master 节点组件

    在Master节点部署组件 在部署Kubernetes之前一定要确保etcd.flannel.docker是正常工作的,否则先解决问题再继续. 创建 CA 证书 mkdir -p /iba/master ...

  7. POJ 2407Relatives

    Relatives Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15566   Accepted: 7900 Descri ...

  8. 从零开始设计数据大屏—基于Vue ZT

    虽然已经决定这个项目用Wyn来做了,但是,了解一下如何从头开始写一个数据大屏还是挺有好玩的. ------------- 为什么要做数据大屏? 现如今的大数据逐渐发挥出了它的力量,并无形的改变着我们的 ...

  9. iOS------Xcode 的clang 扫描器可以检测出所有的内存泄露吗

    在苹果没有出ARC(自动内存管理机制)时,我们几乎有一半的开发时间都耗费在这么管理内存上.后来苹果很人性的出了ARC,虽然在很大程度上,帮助我们开发者节省了精力和时间.但是我们在开发过程中,由于种种原 ...

  10. Android 组件的三种点击事件写法

    一.准备工作 1.项目结构 2.布局文件(activity_main.xml) <?xml version="1.0" encoding="utf-8"? ...