POJ 1017:Packets
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 47513 | Accepted: 16099 |
Description
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
size 6*6. The end of the input file is indicated by the line containing six zeros.
Output
``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
题意是装箱子,给的箱子是6*6*h,物品有1*1*h的,2*2*h的,3*3*h的,4*4*h的,5*5*h的,6*6*h的,给你每一种的数量,然后问需要多少个箱子。
高度都是h,所以就是平面的,然后从大到小一直贪下去。
代码:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int a[8]; int main()
{
int sum;
while(cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6])
{
if(a[1]+a[2]+a[3]+a[4]+a[5]+a[6]==0)
break;
sum=0; sum+=a[6]; sum+=a[5];
a[1]=max(0,a[1]-11*a[5]); sum+=a[4];
if(a[2]>=a[4]*5)
a[2]=a[2]-a[4]*5;
else
{
a[1]=max(0,a[1]-(a[4]*5-a[2])*4);
a[2]=0;
} sum+=(a[3]+3)/4;
int yu3=a[3]%4;
if(yu3==1)
{
a[2]=max(0,a[2]-5);
a[1]=max(0,a[1]-7);
}
else if(yu3==2)
{
a[2]=max(0,a[2]-3);
a[1]=max(0,a[1]-6);
}
else if(yu3==3)
{
a[2]=max(0,a[2]-1);
a[1]=max(0,a[1]-5);
} sum += (a[2]+8)/9;
int yu2 = a[2]%9;
if(yu2>0)
a[1]=max(0,a[1]-(36-yu2*4)); sum += (a[1]+35)/36;
cout<<sum<<endl;
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 1017:Packets的更多相关文章
- POJ 1017 Packets【贪心】
POJ 1017 题意: 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. 这些产品通常 ...
- POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)
http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...
- POJ 3252:Round Numbers
POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...
- 【九度OJ】题目1017:还是畅通工程 解题报告
[九度OJ]题目1017:还是畅通工程 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1017 题目描述: 某省调查乡村交通 ...
- poj 1017 Packets 裸贪心
Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43189 Accepted: 14550 Descrip ...
- Poj 1017 / OpenJudge 1017 Packets/装箱问题
1.链接地址: http://poj.org/problem?id=1017 http://bailian.openjudge.cn/practice/1017 2.题目: 总时间限制: 1000ms ...
- Greedy:Packets(POJ 1017)
装箱问题1.0 题目大意:就是一个工厂制造的产品都是正方形的,有1*1,2*2,3*3,4*4,5*5,6*6,高度都是h,现在要包装这些物品,只能用6*6*h的包装去装,问你怎么装才能使箱子打到最小 ...
- POJ 1017 Packets
题意:有一些1×1, 2×2, 3×3, 4×4, 5×5, 6×6的货物,每个货物高度为h,把货物打包,每个包裹里可以装6×6×h,问最少几个包裹. 解法:6×6的直接放进去,5×5的空隙可以用1× ...
- poj 1017 Packets 贪心
题意:所有货物的高度一样,且其底面积只有六种,分别为1*1 2*2 3*3 4*4 5*5 6*6的,货物的个数依次为p1,p2,p3,p4,p5,p6, 包裹的高度与货物一样,且底面积就为6*6,然 ...
随机推荐
- 通过 Service 访问 Pod【转】
本节开始学习 Service.我们不应该期望 Kubernetes Pod 是健壮的,而是要假设 Pod 中的容器很可能因为各种原因发生故障而死掉.Deployment 等 controller 会通 ...
- NCSC敦促开发者淘汰Python 2
导读 Python 2.x即将结束生命,英国国家网络安全中心(NCSC)敦促开发人员尽快从Python 2.x迁移到Python 3.x.越快越好.Python 2.x将于2020年1月1日停止使用, ...
- POJ 3436:ACM Computer Factory 网络流
ACM Computer Factory Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6247 Accepted: 2 ...
- 单片机ADC检测4-20mA电路,以及计算方法
单片机ADC检测4-20mA电路,以及计算方法 转载:https://www.hongchangzidonghua.com/?id=24 1,手里有一个4-20mA输出的压力传感器,假设测量范围是0M ...
- 连接mysql报错java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized...解决方法
报错内容: java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents mo ...
- 035、Java中自增之++在后面的写法
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- u盘使用记录、痕迹删除技巧方法
在日常生活的使用U盘过程当中,系统会记录下大量U盘的使用记录信息,那么接下来小编就来同大家分享介绍如何删除掉这些使用记录的方法知识. 1. 往系统里面添加环境变量devmgr_shownonprese ...
- ApplicationListener监听使用ContextRefreshedEvent事件类型会触发多次
@Componentpublic class TestApplicationListener implements ApplicationListener<ContextRefreshedEve ...
- 51nod 1179:最大的最大公约数
1179 最大的最大公约数 题目来源: SGU 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 给出N个正整数,找出N个数两两之间最大公约数的最大值 ...
- MongoDB 3.2 升级至 3.4.6
MongoDB 升级测试步骤:1.MongoDB版本升级顺序3.2->3.4->3.6->4.0 不能跨版本升级2.升级到3.4后,您不能降级到3.2.7或更早版本.您只能降级到3. ...