POJ1017 packets

时间:2021-02-13 22:44:10
Packets
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 48911   Accepted: 16570

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

Source

[Submit]   [Go Back]   [Status]   [Discuss]

 #include<cstdio>
#include<iostream>
using namespace std; int main()
{
int n, a, b, c, d, e, f, y, x; // n用来存放箱子数,y用来存放2*2的空位数,x用来存放1*1的空位数。
int u[] = {, , , }; // u表示3*3箱子数目为4的倍数,4的倍数+1,4的倍数+2,4的倍数+3时,为3*3产品打开新箱子中2*2的空位数。
while() {
cin >> a >> b >> c >> d >> e >> f;
if(a == && b == && c == && d == && e == && f == ) break;
n = f + e + d + (c + ) / ; // **计算技巧,(c + 3)/4等于c除以4向上取整。
y = * d + u[c % ];
if(b > y) n += (b - y + ) / ;
x = * n - * f - * e - * d - * c - * b;
if(a > x) n += (a - x + ) / ;
cout << n << endl;
}
return ;
}

POJ1017 packets的更多相关文章

  1. poj-1017 Packets (贪心)

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

  2. 《挑战程序设计竞赛》2&period;2 贪心法-其它 POJ3617 3069 3253 2393 1017 3040 1862 3262

    POJ3617 Best Cow Line 题意 给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下列任意操作: 从S的头部(或尾部)删除一个字符,加到T的尾部 ...

  3. Packets&lpar;模拟 POJ1017&rpar;

    Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 47750 Accepted: 16182 Description ...

  4. 【poj1017】 Packets

    http://poj.org/problem?id=1017 (题目链接) 题意 一个工厂制造的产品形状都是长方体盒子,它们的高度都是 h,长和宽都相等,一共有六个型号,分别为1*1, 2*2, 3* ...

  5. 【Poj1017】Packets

    http://poj.org/problem?id=1017 艰难啊 弄了很久咧 拍了几十万组,以后拍要多组数据 Solution 从大wangxiaofang 从大往小放,有空余的从大往小填 注意细 ...

  6. POJ1017&amp&semi;&amp&semi;UVA311 Packets&lpar;中文题面版&rpar;

    感谢有道翻译--- Description A工厂生产的产品是用相同高度h的方形包装,尺寸为1* 1,2 * 2,3 * 3,4 * 4,5 * 5,6 6.这些产品总是以与产品高度h相同,尺寸为66 ...

  7. The last packet sent successfully to the server was 0 milliseconds ago&period; The driver has not received any packets from the server&period;

    今天项目中报了如下错误 The last packet sent successfully to the server was 0 milliseconds ago. The driver has n ...

  8. RUDP之二 —— Sending and Receiving Packets

    原文链接 原文:http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/ Send ...

  9. PCI Express&lpar;三&rpar; - A story of packets&comma; stack and network

    原文出处:http://www.fpga4fun.com/PCI-Express3.html Packetized transactions PCI express is a serial bus. ...

随机推荐

  1. 傅盛:如何快慢&ldquo&semi;炼&rdquo&semi;金山?(转)

    原文地址:http://www.huxiu.com/article/16052/1.html 一直以来,金山都不是一家"大公司",从前不是,现在也不是. 能够掰着指头数完腾讯六大事 ...

  2. 【iOS】Quartz2D简单介绍

    一.什么是Quartz2D Quartz 2D是⼀个二维绘图引擎,同时支持iOS和Mac系统 Quartz 2D能完成的工作: 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图 ...

  3. java集合 之 Collection和Iterator接口

    Collection是List,Queue和Set接口的父接口,该接口里定义的方法即可用于操作Set集合,也可以用于List和Queue集合.Collection接口里定义了如下操作元素的方法. bo ...

  4. Windows Azure中对映像的管理及操作

    映像是用作新虚拟机的创建模板的 .vhd 文件.映像是一个模板,因为它与已配置的虚拟机不同,没有计算机名称和用户帐户设置等特定设置.可以通过 Windows Azure 管理门户使用现有映像,或创建您 ...

  5. BZOJ 1179 &lbrack;Apio2009&rsqb;Atm(强连通分量)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1179 [题目大意] 给出一张有向带环点权图,给出一些终点,在路径中同一个点的点权只能累 ...

  6. OAuth和OpenID的区别&lpar;转&rpar;

    OAuth(开放授权)是一个开放标准,允许用户让第三方应用访问该用户在某一网站上存储的私密的资源(如照片,视频,联系人列表),而无需将用户名和密码提供给第三方应用.  OAuth协议为用户资源的授权提 ...

  7. Vue中结合Flask与Node&period;JS的异步加载功能实现文章的分页效果

    你好!欢迎阅读我的博文,你可以跳转到我的个人博客网站,会有更好的排版效果和功能. 此外,本篇博文为本人Pushy原创,如需转载请注明出处:http://blog.pushy.site/posts/15 ...

  8. 就这么 来ADO&period;net类操作数据库

    使用ADO.net操作数据库其实也是很简单,而且使用频率蛮高的一种方式.话不多说,上代码才更容易理解. 首先,先要引入数据库操作相关的命名空间,这样才能使用下面的代码 //数据库连接引用的命名空间 u ...

  9. 【爆料】-《澳大利亚联邦大学毕业证书》FedUni一模一样原件

    ☞澳大利亚联邦大学毕业证书[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士& ...

  10. (转)区块链共识机制分析——论PoW,PoS,DPos和DAG的优缺点

    近期,随着区块链技术在社区中的声音越来越大,业界已经开始从技术角度对区块链进行全方位的解读.作为第一批区块链技术的实现,传统比特币与以太坊在共识机制.存储机制.智能合约机制.跨链通讯机制等领域并没有非 ...