题意:有一些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. SVN备份教程(一)

    最近一段时间在项目中用到了SVN备份的相关内容,这里给大家做一个简单的教程,重点在于SVN备份环境的搭建过程中,大家学到的解决问题的思维方式. 1.分类 SVN备份主要分为两种:一种是远程备份,另一种 ...

  2. Jplayer(转)

    Jplayer必须要加载 1.样式  jplayer.blue.monday.css 2.jq jquery.1.6.2.min.js 当前最新版本为1.6.2 3.jplayer的js jquery ...

  3. sql server 2012 5120错误

    把放置放置数据库的文件夹的权限更改为完全控制即可解决这个问题.

  4. uva 701

    参考了一下http://hi.baidu.com/renxl51/item/e80b688f9f54aadd5e0ec1de 给一个数字x,求最小的正整数e,使得pow(2,e) == x*pow(1 ...

  5. HDU4720+三角形外接圆

    /* 几何 求给定三角形的外接圆圆心 方法:求解二元方程组 */ #include<stdio.h> #include<string.h> #include<math.h ...

  6. hdu 3544 Alice's Game 博弈论

    博弈论+二分! 后一人会尽量选前一人切小的一块切!! 代码如下: #include<iostream> #include<stdio.h> #define I1(x) scan ...

  7. android 使用系统照相程序照相并存储、显示在界面上

    大部分业务可以通过调用系统的相机程序来拍照. 界面如下: <?xml version="1.0" encoding="utf-8"?> <Li ...

  8. linux ubuntu 11.04 samba 服务器设置

    安装 SAMBA 组件 sudo apt-get install samba smbfs smbclient   配置相关参数 sudo gedit /etc/samba/smb.conf 文件中相关 ...

  9. [Unity菜鸟] 术语

    HUD Mozilla  Mozilla基金会,简称Mozilla(缩写MF或MoFo),是为支持和领导开源的Mozilla项目而设立的一个非营利组织. 称作Mozilla公司的子公司,雇佣了一些Mo ...

  10. Maven中聚合与继承

    何为继承? --›继承为了消除重复,我们把很多相同的配置提取出来 --›例如:grouptId,version等 就像写java程序一样,对于有共性切重复的东西,就提取出来. 如有三个pom.xml配 ...