Poj 1017 / OpenJudge 1017 Packets/装箱问题
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/装箱问题的更多相关文章
- 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 ...
- Poj 1328 / OpenJudge 1328 Radar Installation
1.Link: http://poj.org/problem?id=1328 http://bailian.openjudge.cn/practice/1328/ 2.Content: Radar I ...
- Poj 2503 / OpenJudge 2503 Babelfish
1.Link: http://poj.org/problem?id=2503 http://bailian.openjudge.cn/practice/2503/ 2.Content: Babelfi ...
- Poj 2262 / OpenJudge 2262 Goldbach's Conjecture
1.Link: http://poj.org/problem?id=2262 http://bailian.openjudge.cn/practice/2262 2.Content: Goldbach ...
- Poj 2159 / OpenJudge 2159 Ancient Cipher
1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...
- Poj 1001 / OpenJudge 2951 Exponentiation
1.链接地址: http://poj.org/problem?id=1001 http://bailian.openjudge.cn/practice/2951 2.题目: Exponentiatio ...
- Poj 1006 / OpenJudge 2977 1006 Biorhythms/生理周期
1.链接地址: http://poj.org/problem?id=1006 http://bailian.openjudge.cn/practice/2977 2.题目: Biorhythms Ti ...
- 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 ...
- 毫秒级检测!你见过带GPU的树莓派吗?
树莓派3B+英特尔神经计算棒进行高速目标检测 转载请注明作者梦里茶 代码: 训练数据预处理: https://gist.github.com/ahangchen/ae1b7562c1f93fdad1d ...
随机推荐
- EntityFramework 连接数据库出错
本文转载:http://www.cnblogs.com/shuang121/archive/2012/03/19/2406121.html 总结:选择“是”时,连接字符串的密码会暴露出来,“否”的时候 ...
- Eclipse+Maven构建web项目及部署时Maven lib依赖问题的解决
目录 Eclipse中m2e插件构建web项目的步骤 Maven工具构建web项目再导入Eclipse的步骤 [一].Eclipse中m2e插件构建web项目的步骤 第一步:创建项目,按照 New – ...
- 安装好Windows 8后必做的几件事情,让你的Win8跑的更快更流畅。
1.关闭家庭组,因为这功能会导致硬盘和CPU处于高负荷状态. 关闭方法:Win+C-设置-更改电脑设置-家庭组-离开 如果用不到家庭组可以直接把家庭组服务也给关闭了:控制面板-管理工具-服务-Home ...
- HP LoadRunner 11 破解及license
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- PHP 文件包含之文件路径截断(转)
PHP 文件包含之文件路径截断 以下是网络摘要: 1. 本来还以为挖到金矿了,跟黑哥交流后发现只能应用于Win32平台,使这个BUG的威力暴减,基本没有太大危害了,因为在WIN32平台使用PHP的实在 ...
- [HTML5] Input accepts only 6 number characters
Use 'pattern' tag in html5: <input type="text" pattern="[0-9]{6}" maxlength=& ...
- 用C++程序理解汉字的机内码表示
汉字的编码是非常多刚開始学习的人不easy搞不明确的事情.最早的汉字字符集是GB2312-80,收入汉字6763个,符号715个,总计7478个字符,大陆普遍使用的简体字字符集.本文借助于一个能输出这 ...
- 【ZT】修复iCloud中查找我的iPhone、查找我的iPad无法显示地图的方法
http://blog.sina.com.cn/s/blog_4ff28d30010118cm.html 进入C:\Windows\System32\drivers\etc在hosts文件里加入如下地 ...
- Java ZIP File Example---refernce
In this tutorial we are going to see how to ZIP a file in Java. ZIP is an archive file format that e ...
- 通过scrollerview自定义collectionview(常用于推荐关注界面)
最近项目上要实现一个效果,先把效果图摆上来吧: 刚看到效果图的时候 我觉得很简单 用UICollectionview就可以了 但是后来发现collectionview只有两种布局方式 比较单一 ...