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,然 ...
随机推荐
- 数学软件实训1-MATLAB程序设计及应用初步
数学软件实训任务一 一 题目:MATLAB程序设计及应用初步 二 目的:掌握MATLAB程序设计的基本方法,会利用MATLAB程序设计思想编程处理一些简单问题. 三 要求: 1 掌握控制流的基本语法结 ...
- Day4 - D - Watchcow POJ - 2230
Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the ...
- python SSTI绕过
原理首先以jinja2模板注入为例:{{request[request.args.param]}} 可以用 {{request|attr(request.args.param)}} 替代绕过" ...
- java csv文件写入
List<String> list_code = null; 方案1 控制字符集: BufferedWriter bw=new BufferedWriter(new OutputStrea ...
- SpringBoot-数据库连接信息配置
SpringBoot-数据库连接信息配置 SpringBoot-数据库连接信息配置 在SpringBoot中提供了默认的数据库连接器-追光者HikariCP,我们只需要添加jdbc的启动器就会自动 ...
- Angular2的双向数据绑定
什么是双向绑定 如图: 双向绑定.jpg 双向绑定机制维护了页面(View)与数据(Data)的一致性.如今,MVVM已经是前段流行框架必不可少的一部分. Angular2中的双向绑定 双向绑定, ...
- git上传流程
转: 1.在github上创建项目 2.使用git clone https://github.com/xxxxxxx/xxxxx.git克隆到本地 3.编辑项目 4.git add . (将改动添加到 ...
- TP框架数据模型
1.TP框架的数据模型需要建在Model文件夹下: 1.数据模型 与控制器相似,但是每个数据模型控制一张数据表. 2.数据模型可写可不写,如果不写 则沿用父类数据模型. 2.访问数据库: 1.更改数据 ...
- 二十五、JavaScript之查找字符串中的字符串indexOf和lastIndexOf的用法
一.代码如下 二.效果如下 <!DOCTYPE html> <html> <meta http-equiv="Content-Type" conten ...
- dp学习笔记(各种dp,比较杂)
HDU1176 中文题意不多解释了. 建一个二维dp数组,dp[ i ][ j ]表示第 i 秒落在 j 处一个馅饼.我们需要倒着DP,为什么呢,从 0秒,x=5处出发,假如沿数组正着往下走,终点到哪 ...