题意:有一些1×1, 2×2, 3×3, 4×4, 5×5, 6×6的货物,每个货物高度为h,把货物打包,每个包裹里可以装6×6×h,问最少几个包裹。

解法:6×6的直接放进去,5×5的空隙可以用1×1的填充,4×4的可以用2×2的和1×1的填充,3×3的四个可以组成一个包裹,多出来的和2×2的和1×1的组合,2×2的9个组成一个包裹,多的和1×1组合,1×1的36个组成一个包裹,按以上顺序模拟一下OTZ也不知道怎么想的……写出好多bug来

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long
using namespace std;
int main()
{
int a, b, c, d, e, f;
while(~scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) && !(a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f == 0))
{
int ans = 0;
ans += f;
ans += e;
int tmp = 11 * e;
a = max(0, a - tmp);
ans += d;
tmp = 5 * d;
if(b < tmp)
{
tmp -= b;//因为这两句写反了找了半天bug……智商拙计
b = 0;
}
else
{
b -= tmp;
tmp = 0;
}
a = max(0, a - tmp * 4);
ans += c / 4;
c %= 4;
tmp = 0;
if(c)
{
ans++;
tmp = 36 - c * 9;
int ttmp = 0;
if(c == 1)
ttmp = 5;
else if(c == 2)
ttmp = 3;
else
ttmp = 1;
tmp -= ttmp * 4;
if(b < ttmp)
{
ttmp -= b;
b = 0;
}
else
{
b -= ttmp;
ttmp = 0;
}
a = max(0, a - ttmp * 4 - tmp);
}
ans += b / 9;
b %= 9;
if(b)
{
ans++;
a = max(0, a - 36 + 4 * b);
}
ans += a / 36;
a %= 36;
if(a)
ans++;
printf("%d\n", ans);
}
return 0;
}

  

POJ 1017 Packets的更多相关文章

  1. POJ 1017 Packets【贪心】

    POJ 1017 题意: 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为 1*1, 2*2, 3*3, 4*4, 5*5, 6*6.  这些产品通常 ...

  2. poj 1017 Packets 裸贪心

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43189   Accepted: 14550 Descrip ...

  3. poj 1017 Packets 贪心

    题意:所有货物的高度一样,且其底面积只有六种,分别为1*1 2*2 3*3 4*4 5*5 6*6的,货物的个数依次为p1,p2,p3,p4,p5,p6, 包裹的高度与货物一样,且底面积就为6*6,然 ...

  4. Poj 1017 Packets(贪心策略)

    一.题目大意: 一个工厂生产的产品用正方形的包裹打包,包裹有相同的高度h和1*1, 2*2, 3*3, 4*4, 5*5, 6*6的尺寸.这些产品经常以产品同样的高度h和6*6的尺寸包袱包装起来运送给 ...

  5. POJ 1017 Packets(积累)

    [题意简述]:这个是别人的博客,有清晰的题意描写叙述.和解题思路,借助他的想法,能够非常好的解决问题! [分析]:贪心?模拟?见代码 //216K 16Ms #include<iostream& ...

  6. Poj 1017 / OpenJudge 1017 Packets/装箱问题

    1.链接地址: http://poj.org/problem?id=1017 http://bailian.openjudge.cn/practice/1017 2.题目: 总时间限制: 1000ms ...

  7. POJ 1017:Packets

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 47513   Accepted: 16099 Descrip ...

  8. Greedy:Packets(POJ 1017)

    装箱问题1.0 题目大意:就是一个工厂制造的产品都是正方形的,有1*1,2*2,3*3,4*4,5*5,6*6,高度都是h,现在要包装这些物品,只能用6*6*h的包装去装,问你怎么装才能使箱子打到最小 ...

  9. POJ - 1017 贪心训练

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 59725   Accepted: 20273 Descrip ...

随机推荐

  1. ajax加php实现三级联动

    js代码 <script type="text/javascript">    function get_next(t,pid){  //当前元素的id,当前optio ...

  2. php+mysql分页类的入门实例

    php+mysql分页类的简单代码 时间:2016-02-25 06:16:26来源:网络 导读:php+mysql分页类的简单代码,二个php分页类代码,对商品进行分页展示,当前页面数,每个页面展示 ...

  3. putty连接linux as5 输入密码后连接中断

    putty连接linux as5 输入密码后连接中断 1.修改putty首页的设置,选择“close session on exit” 为 “never”,之后发现输入密码后,“session clo ...

  4. sshj ,ssh , springmvc pom.xml

    记录下项目中的 pom文件 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ ...

  5. 三年PS经验

  6. DWR

    DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站.它可以允许在浏览器里的代码使用运行在 ...

  7. uva 10562

    二叉树的先序遍历  这个还是比较简单的 ~~ /************************************************************************* &g ...

  8. Jmeter 使用实践 - 接口 diff 测试

    大多数人都使用 Jmeter 做过性能测试,但是在使用的过程中你会发现,它不仅可以做性能测试和功能测试,还能够满足基本的接口测试需求. 相比其他工具,Jmeter 入门门槛较低,安装也比较方便,根据自 ...

  9. Hex string convert to integer with stringstream

    #include <sstream>#include <iostream>int main() { unsigned int x; std::stringstream ss; ...

  10. eclipse查看jar包中class的中文注释乱码问题的解决

    1,问题来源是在eclipse中直接查看springside的class(由eclipse自动反编译)里面注释的乱码问题: Preferences-General-Workspace-Text fil ...