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. 一个方便的shell命令,查看软件安装目录

    查看软件安装路径:whereis phpfind / -name nginx.configfind 查找 / 从根目录 -name 文件查找

  2. Codeforces Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学

    C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  3. 用普通IO驱动LCD的控制方法-松瀚汇编源程序

    /*************************************** 本例程为IO直接驱动LCD的方法 以下是松瀚MCU汇编源程序 **************************** ...

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

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

  5. MySQL 性能监控 4 大指标

    [编者按]本文作者为 John Matson,主要介绍 mysql 性能监控应该关注的 4 大指标. 文章系国内 ITOM 管理平台 OneAPM 编译呈现.    MySQL 是什么? MySQL  ...

  6. JQuery图片滑动插件

    效果预览: (暂无) html代码: <div id="focus"> <ul> <li> <a href="#"&g ...

  7. iOS 图片加载框架- SDWebImage 解读

    在iOS的图片加载框架中,SDWebImage可谓是占据大半壁江山.它支持从网络中下载且缓存图片,并设置图片到对应的UIImageView控件或者UIButton控件.在项目中使用SDWebImage ...

  8. C# 之 Word光标移动 GoTo 方法

    对于 Document 或 Range对象:返回一个 Range对象,该对象代表指定项(例如页.书签或域)的开始位置. 对于 Selection对象:将插入点移至指定项前面的字符位置,并返回一个 Ra ...

  9. h5拖放-ff的bug

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  10. 在 Ubuntu 16.04 中安装谷歌 Chrome 浏览器

    进入 Ubuntu 16.04 桌面,按下 Ctrl + Alt + t 键盘组合键,启动终端. 也可以按下 Win 键(或叫 Super 键),在 Dash 的搜索框中输入 terminal 或&q ...