poj-1017 Packets (贪心)
http://poj.org/problem?id=1017
工厂生产高度都为h,长和宽分别是1×1 2×2 3×3 4×4 5×5 6×6的6种规格的方形物品,交给顾客的时候需要包装,包装盒长宽高都为6×6,高度为h,为了减少成本,问至少需要多少包装盒才能把全部物品装进去。每一行有6个数,分别表示1×1 2×2 3×3 4×4 5×5 6×6的物品有多少个。
从大到小处理,先放6×6的放一个就需要一个盒子,在放5×5的,每一个也需要一个盒子,但是还可以放11个1×1的物品,放4×4的物品的时候,还可以放2×2的和1×1的,最复杂的事放3×3的,有多种情况需要考虑,要细心,我也是用了别人的测试数据才改出来的。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define ll long long
#define inf 0x7f7f7f7f
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0) #define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define Read() freopen("a.txt", "r", stdin)
#define Write() freopen("b.txt", "w", stdout);
#define maxn 1000000000
#define N 10010
using namespace std; int main()
{
//Read();
//Write()
int a,b,c,d,e,f,s;
while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f))
{
if(a+b+c+d+e+f==) break;
s=f; //6*6的
if(e>) //5*5的
{
s+=e;
a-=*e;
}
//printf("%d %d\n",s,a);
if(d>) //4×4的
{
s+=d;
int b1=*d; //可以放 b1个2×2的
b-=b1;
if(b<) //2×2不够,就放1×1的
{
a-=-*b;
}
}
//printf("%d %d %d\n",s,a,b);
if(c>)
{
s+=c/;
int c1=c%;
if(c1)
{ //分情况讨论,c1=1,=2,=3
s++;
if(b>)
{
int b1=b;
if(c1==) b-=;
else if(c1==) b-=;
else if(c1==) b-=;
if(b>=) a-=-c1*-(b1-b)*; //还可以放1×1的
else a-=-c1*-b1*;
}
else a-=-c1*;
}
}
// printf("%d %d %d\n",s,a,b);
if(b>) //2×2 的
{
s+=b/;
int b1=b%;
if(b1)
{
s++;
if(a>) a-=-b1*;
}
}
if(a>) //1×1 的
{
s+=a/;
if(a%>) s++;
}
printf("%d\n",s);
}
return ;
}
poj-1017 Packets (贪心)的更多相关文章
- Poj 1017 Packets(贪心策略)
一.题目大意: 一个工厂生产的产品用正方形的包裹打包,包裹有相同的高度h和1*1, 2*2, 3*3, 4*4, 5*5, 6*6的尺寸.这些产品经常以产品同样的高度h和6*6的尺寸包袱包装起来运送给 ...
- poj 1017 Packets 贪心
题意:所有货物的高度一样,且其底面积只有六种,分别为1*1 2*2 3*3 4*4 5*5 6*6的,货物的个数依次为p1,p2,p3,p4,p5,p6, 包裹的高度与货物一样,且底面积就为6*6,然 ...
- POJ 1017 Packets【贪心】
POJ 1017 题意: 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. 这些产品通常 ...
- poj 1017 Packets 裸贪心
Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43189 Accepted: 14550 Descrip ...
- poi 1017 Packets 贪心+模拟
Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 48349 Accepted: 16392 Descrip ...
- POJ 1017 Packets(积累)
[题意简述]:这个是别人的博客,有清晰的题意描写叙述.和解题思路,借助他的想法,能够非常好的解决问题! [分析]:贪心?模拟?见代码 //216K 16Ms #include<iostream& ...
- POJ 1O17 Packets [贪心]
Packets Description A factory produces products packed in square packets of the same height h and of ...
- 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 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 59725 Accepted: 20273 Descrip ...
- Poj 1017 / OpenJudge 1017 Packets/装箱问题
1.链接地址: http://poj.org/problem?id=1017 http://bailian.openjudge.cn/practice/1017 2.题目: 总时间限制: 1000ms ...
随机推荐
- Codeforces Round #281 (Div. 2)
题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football gam ...
- 【BZOJ】【1018】【SHOI2008】堵塞的交通traffic
线段树 这题的线段树+分类讨论蛮神奇的……我以前学的线段树简直就是渣渣QAQ 看了下ydc题解里的思想>_>用线段树维护连通性!那么就自己写吧……每个节点表示一段区间的连通性(我的叶子节点 ...
- Hibernate O/R Mapping模拟
作为SSH中的重要一环,有必要理解一下Hibernate对 O/R Mapping的实现. 主要利用java的反射机制来得到完整的SQL语句. 准备工作: 1. Object Student实体类: ...
- context--command buffer
今天看了下 context ,因为要找怎么设置command buffer context为设备提供一些状态的设置和管理command buffer & const buffer buffe ...
- std::vector<Channel2*> m_allChannels;容器,以及如何根据channelid的意义
std::vector<Channel2*> m_allChannels;容器,以及如何根据channelid的意义 这个容器保存了所有客户端连接的channel Channel2* Li ...
- Sqli-labs less 17
Less-17 本关我们可以看到是一个修改密码的过程,利用的是update语句,与在用select时是一样的,我们仅需要将原先的闭合,构造自己的payload. 尝试报错 Username:admin ...
- __dict__和__slots__
__dict__: __slots__:
- codeforces 459C Pashmak and Buses(模拟,组合数A)
题目 跑个案例看看结果就知道了:8 2 3 题目给的数据是 n,k,d 相当于高中数学题:k个人中选择d个人排成一列,有多少种不同的方案数,列出其中n中就可以了. #include<iostre ...
- LCS最长公共子序列(最优线性时间O(n))
这篇日志主要为了记录这几天的学习成果. 最长公共子序列根据要不要求子序列连续分两种情况. 只考虑两个串的情况,假设两个串长度均为n. 一,子序列不要求连续. (1)动态规划(O(n*n)) (转自:h ...
- 获取及管理Android 手机运营商及状态
主要类 TelephonyManager: telephonyManager.getCellLocation();//获得服务区 telephonyManager.getCellId();//获得服务 ...