1.链接地址:

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

http://bailian.openjudge.cn/practice/1017

2.题目:

总时间限制:
1000ms
内存限制:
65536kB
描述
一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为1*1, 2*2, 3*3, 4*4, 5*5, 6*6。这些产品通常使用一个 6*6*h 的长方体包裹包装然后邮寄给客户。因为邮费很贵,所以工厂要想方设法的减小每个订单运送时的包裹数量。他们很需要有一个好的程序帮他们解决这个问题从而节 省费用。现在这个程序由你来设计。
输入
输入文件包括几行,每一行代表一个订单。每个订单里的一行包括六个整数,中间用空格隔开,分别为1*1至6*6这六种产品的数量。输入文件将以6个0组成的一行结尾。
输出
除了输入的最后一行6个0以外,输入文件里每一行对应着输出文件的一行,每一行输出一个整数代表对应的订单所需的最小包裹数。
样例输入
0 0 4 0 0 1
7 5 1 0 0 0
0 0 0 0 0 0
样例输出
2
1
来源
Central Europe 1996

3.思路:

数学题,分为多种情况

4.代码:

 #include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
const int NUM = ;
int res[NUM];
int main()
{
int x6,x5,x4,x3,x2,x1;
cin>>x1>>x2>>x3>>x4>>x5>>x6;
while(x1 + x2 + x3 + x4 + x5 + x6 > )
{
for(int i = ; i < NUM; i++) res[i] = ;
int sum = ; sum += x6; sum += x5;
res[] -= *x5; sum += x4;
res[] -= *x4; sum += x3/;
int tmp = x3 % ;
if(tmp == )
{
sum += ;
res[] -= ;
res[] -= ;
}
else if(tmp == )
{
sum += ;
res[] -= ;
res[] -= ;
}
else if(tmp == )
{
sum += ;
res[] -= ;
res[] -= ;
} if(x2 + res[] <= ) res[] += * (res[] + x2);
else
{
sum += (x2 + res[] + ) / ;
res[] -= ( - (x2 + res[]) % ) * ;
} if(x1 + res[] > ) sum += (x1 + res[] + ) / ; cout<<sum<<endl; cin>>x1>>x2>>x3>>x4>>x5>>x6;
}
return ;
}

Poj 1017 / OpenJudge 1017 Packets/装箱问题的更多相关文章

  1. Poj 2109 / OpenJudge 2109 Power of Cryptography

    1.Link: http://poj.org/problem?id=2109 http://bailian.openjudge.cn/practice/2109/ 2.Content: Power o ...

  2. Poj 1328 / OpenJudge 1328 Radar Installation

    1.Link: http://poj.org/problem?id=1328 http://bailian.openjudge.cn/practice/1328/ 2.Content: Radar I ...

  3. Poj 2503 / OpenJudge 2503 Babelfish

    1.Link: http://poj.org/problem?id=2503 http://bailian.openjudge.cn/practice/2503/ 2.Content: Babelfi ...

  4. Poj 2262 / OpenJudge 2262 Goldbach's Conjecture

    1.Link: http://poj.org/problem?id=2262 http://bailian.openjudge.cn/practice/2262 2.Content: Goldbach ...

  5. Poj 2159 / OpenJudge 2159 Ancient Cipher

    1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...

  6. Poj 1001 / OpenJudge 2951 Exponentiation

    1.链接地址: http://poj.org/problem?id=1001 http://bailian.openjudge.cn/practice/2951 2.题目: Exponentiatio ...

  7. Poj 1006 / OpenJudge 2977 1006 Biorhythms/生理周期

    1.链接地址: http://poj.org/problem?id=1006 http://bailian.openjudge.cn/practice/2977 2.题目: Biorhythms Ti ...

  8. Poj 2586 / OpenJudge 2586 Y2K Accounting Bug

    1.Link: http://poj.org/problem?id=2586 2.Content: Y2K Accounting Bug Time Limit: 1000MS   Memory Lim ...

  9. 毫秒级检测!你见过带GPU的树莓派吗?

    树莓派3B+英特尔神经计算棒进行高速目标检测 转载请注明作者梦里茶 代码: 训练数据预处理: https://gist.github.com/ahangchen/ae1b7562c1f93fdad1d ...

随机推荐

  1. 将java源码打成jar包

    方法一:通过jar命令 jar命令的用法: 下面是jar命令的帮助说明: 用法:jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] ...

  2. Postfix上的反垃圾邮件的四个方法

    在介绍如何配置Postfix的smtp配置之前有必要首先介绍一下它的背景和特点.Postfix是一个由IBM资助下由WietseVenema 负责开发的自由软件工程的一个产物,其目的是为用户提供除se ...

  3. C#-动态生成40个按钮,大小(20,20),要求每行6个放置

    应该为for (int i=0;i<基本数据DataSet3.Tables [0].Rows .Count ;i++)                 {                 int ...

  4. Aizu 2450 Do use segment tree 树链剖分+线段树

    Do use segment tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.bnuoj.com/v3/problem_show ...

  5. zookeeper使用场景【转】

    分布式网站架构后续:zookeeper技术浅析   Zookeeper是hadoop的一个子项目,虽然源自hadoop,但是我发现zookeeper脱离hadoop的范畴开发分布式框架的运用越来越多. ...

  6. android学习日记13--数据存储之SQLite

    2.SQLite 开源轻量级数据库,支持92-SQL标准,主要用于嵌入式系统,只占几百K系统资源此外,SQLite 不支持一些标准的 SQL 功能,特别是外键约束(FOREIGN KEY constr ...

  7. sphinx配置文件继承

    # # Minimal Sphinx configuration sample (clean, simple, functional) # source mysql { type = mysql #数 ...

  8. android的进度条使用

    android的进度条 1.实现的效果 2.布局代码 先写一个my_browser.xml文件 存放WebView <?xml version="1.0" encoding= ...

  9. jQuery执行请求demo

    Ajax教程地址 4.3.2 执行GET请求 使用jQuery来执行GET请求有多种可选的方法.最简单的方法是使用$.get(),其参数是一个URL和一个回调函数:该回调函数有两个参数:一个是从服务器 ...

  10. Asp.Net 之 获取GridView行的DataKeys

    1.后台任意一个位置获取GridView行的主键值 foreach (GridViewRow row in GridView1.Rows) { string order_Id=this.GridVie ...