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 ...
随机推荐
- 人工智能-有限状态机(FSM)的学习
首先声明:此文源于本人最近学习的一本书 <游戏人工智能编程案例精粹> FSM的定义: 一个有限状态机是一个设备,或是一个设备模型,具有有限数量的状态,它可以在任何给定的时间根据输入进行操作 ...
- iOS UICollectionView基础
转载自:http://www.cnblogs.com/wayne23/p/4013522.html 初始化部分: UICollectionViewFlowLayout *flowLayout= [[ ...
- 导出cluster log
将所有群集节点的日志导出到 clog 目录下: get-clusterlog -destination c:\clog 只导出前10分钟的群集日志: get-cluster -destination ...
- SQL索引详解
转自:http://www.cnblogs.com/AK2012/archive/2013/01/04/2844283.html SQL索引在数据库优化中占有一个非常大的比例, 一个好的索引的设计,可 ...
- 一个Solr搜索实例,增删改查+高亮+分页
今天个人coding的模块测试,所以闲暇之余继续研究solr,然后顺带写了一个实例,随便搞的,solr真心不熟,期待认识热爱搜索的朋友,共同进步. 1.配置schema.xml文件[solr\coll ...
- [HTML5] Input accepts only 6 number characters
Use 'pattern' tag in html5: <input type="text" pattern="[0-9]{6}" maxlength=& ...
- android132 360 05 手机定位
.网络定位:根据ip地址定位,根据ip地址在实际地址数据库中查询实际地址. 缺点:动态ip导致地址不准确. .基站定位:3个基站就可以确定实际位置,定位范围是几百米到几公里不等. .GPS定位:美国卫 ...
- android119 侧滑菜单
MainActivity.java package com.heima52.slidemenu; import com.heima52.slidemenu.view.SlideMenu; import ...
- android中设置快捷键方法setShortcut参数的说明
setShortcut之所以要两个参数来设定两个快捷键是为了应对不同的手机键盘.数字快捷键为12键键盘(0~9,*,#,共12个按键)所准备的.其实我怀疑有这种键盘的手机能装Android么?因为我的 ...
- javaScript面向对象基础
最近学习了js的面向对象,为了能让自己更好的理解,这一篇博客就当作是加深自己学习印象的总结(可能会有很多不足,欢迎指正). js通过函数来创建对象,而且js本身也是一种对象,那么什么又是对象呢,对象包 ...