Packets
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 41014   Accepted: 13776

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
#include <stdio.h>
#include <string.h> int main(){
int a,b,c,d,e,f;
int al, bl;
int total;
int tmp; a = b = c = d = e = f = 0; while(1){
total = 0;
tmp = 0;
al = bl = 0;
scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f); if(a == 0&& b == 0 && c == 0&& d == 0 && e == 0 && f ==0){
break;
} /*
6*6
*/
total += f;
/*
5*5
*/
if(e>0){
total += e;
al += 11 * e;
} /*
4*4
*/
if(d>0){
total += d;
bl += 5 * d;
} /*
3*3
*/
if(c > 0){
tmp = (c%4 == 0)? 0:1;
total += (c/4 + tmp);
tmp = c%4;
if(tmp == 1){
al += 7;
bl += 5;
}
else if(tmp == 2){
al += 6;
bl += 3;
}
else if(tmp == 3){
al += 5;
bl += 1;
}
} /*
2 * 2
*/
if(b > 0){
if(b<=bl) {
al += 4 * (bl - b);
bl = 0;
b = 0;
}
else{
b -= bl;
bl = 0;
}
} if(b > 0){
tmp = (b%9 == 0)? 0:1;
total += (b/9 + tmp);
if(b%9 !=0){
al += 36 - 4*(b %9);
}
b = 0;
} al += bl * 4; if(a > 0){
if(a<=al){
a = 0;
}
else{
a = a - al;
}
} tmp = (a%36 == 0)? 0:1;
total += (a/36 + tmp);
printf("%d\n", total);
} return 0;
}

  

[poj解题]1017的更多相关文章

  1. POJ解题经验交流

    感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理.   题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...

  2. 【poj解题】1028

    stack的应用 #include<iostream> #include<stack> #include<stdio.h> #include<stdlib.h ...

  3. 【poj解题】3664

    简单,两次排序 #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 500 ...

  4. 【poj解题】3663

    排序, 遍历,需要裁减 #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX ...

  5. 【poj解题】1308

    判断一个图是否是一个树,树满足一下2个条件即可:1. 边树比node数少12. 所有node的入度非0即1 节点数是0的时候,空树,合法树~ 代码如下 #include <stdio.h> ...

  6. 洛谷 P1731 [NOI1999]生日蛋糕 && POJ 1190 生日蛋糕

    题目传送门(洛谷)  OR 题目传送门(POJ) 解题思路: 一道搜索题,暴力思路比较容易想出来,但是这道题不剪枝肯定会TLE.所以这道题难点在于如何剪枝. 1.如果当前状态答案已经比我们以前某个状态 ...

  7. POJ 1017

    http://poj.org/problem?id=1017 题意就是有6种规格的物品,给你一些不同规格的物品,要求你装在盒子里,盒子是固定尺寸的也就是6*6,而物品有1*1,2*2,3*3,4*4, ...

  8. POJ 1003 解题报告

    1.问题描述: http://poj.org/problem?id=1003 2.解题思路: 最直观的的想法是看能不能够直接求出一个通项式,然后直接算就好了, 但是这样好水的样子,而且也不知道这个通项 ...

  9. POJ 1004 解题报告

    1.题目描述: http://poj.org/problem?id=1004 2.解题过程 这个题目咋一看很简单,虽然最终要解出来的确也不难,但是还是稍微有些小把戏在里面,其中最大的把戏就是float ...

随机推荐

  1. Ansible11:变量详解【转】

    一.在Inventory中定义变量 详见<Ansible2:主机清单> 二.在Playbook中定义变量 1.通过vars关键字定义: vars: http_port: 80 server ...

  2. asp.net无法触发asp控件的后台方法

    前台代码: <asp:Button ID="btnFinish" runat="server" Text="完成" Font-Size ...

  3. Oracle 游标及存储过程实例

    /*********实例一*********/ create or replace procedure users_procedure is cursor users_cursor is select ...

  4. Unable to chmod /system/build.prop.: Read-only file system

    Unable to chmod /system/build.prop.: Read-only file system 只读文件系统 所以需要更改 使用下面的命令 mount -o remount,rw ...

  5. Python 线程,进程

    Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元 线程不能实现多并发 只能实现伪并发 每次工作 只能是一个线程完成 由于python解释器 原生是c  原生线程 底层都会有一把 ...

  6. Notification使用笔记

    之前在项目中使用了Notification,现分享出来: checkNotification() function checkNotification(){ //判断是否支持Notification ...

  7. scull_p_read()函数分析

    /* * Data management: read and write */ static ssize_t scull_p_read (struct file *filp, char __user ...

  8. Lucene 简单手记http://www.cnblogs.com/hoojo/archive/2012/09/05/2671678.html

    什么是全文检索与全文检索系统? 全文检索是指计算机索引程序通过扫描文章中的每一个词,对每一个词建立一个索引,指明该词在文章中出现的次数和位置,当用户查询时,检索程序就根据事先建立的索引进行查找,并将查 ...

  9. 【从汉字中提取数字】不用公式,不用VBA,如此简单的方法你是否用过?

    转自:http://huaban.com/pins/19664410 具体操作过程请看附图动画:

  10. Linux 下 git的使用

    参考链接:http://www.liaoxuefeng.com 安装 安装步骤: ①先给操作系统装入git工具,以Linux为例: $ sudo apt-get install git ②去githu ...