题意:有一些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. oracle 导入报错 ORA-00959: tablespace 'HB' does not exist

    导入oracle 时发现有几张表导入时一直报错: 报错信息:IMP-00003: ORACLE error 959 encountered   ORA-00959: tablespace 'HB' d ...

  2. 关于Javascript"数组"那点事儿

    记住Javascript里没有“数组”忘掉一切吧,骚年...一切都是对象:书中还细分了下简单类型和对象类型基本类型:typeof xxx => "number"数字,&quo ...

  3. MVC4多语言IHttpModule实现

    最近项目需要多语言环境了. 由于项目页面较多,逐个Action去读取资源文件不大现实.就想到了使用 IHttpModule配合MVC的路由规则来实现. 首先创建以个mvc4的应用程序,添加资源文件夹( ...

  4. Objective C 四舍五入,float处理

    NSLog(@"平方:%.f", pow(3,2) ); //result 9 NSLog(@"上舍入:%.f", ceil(3.000000000001)); ...

  5. 区分JS中的undefined,null,"",0和false

    在程序语言中定义的各种各样的数据类型中,我们都会为其定义一个"空值"或"假值",比如对象类型的空值null,.NET Framework中数据库 字段的空值DB ...

  6. [itint5]单词游戏

    http://www.itint5.com/oj/#36 此题在数据大些,而且全是A的情况下会超时(因为要匹配到很后面才false).通过利用数组本身作为visited标示,而且使用string引用, ...

  7. Linux中的栈:用户态栈/内核栈/中断栈

    http://blog.chinaunix.net/uid-14528823-id-4136760.html Linux中有多种栈,很容易弄晕,简单说明一下: 1.用户态栈:在进程用户态地址空间底部, ...

  8. Altium Designer13 如何导出Gerber文件

    参考<http://blog.sina.com.cn/s/blog_9b9a51990100zyyv.html> 版本:AD13.3.4 目的:Gerber文件导出备忘 目录: Step1 ...

  9. 如何:在 Winform 动态启动、控制台命令行?

    需求   winForm 程序输出类型为 windows 程序(不是命令行程序)   在运行时想输入一些信息编译开发调试,如何实现这一功能 解答:  AllocConsole.FreeConsole ...

  10. 210. Course Schedule II

    题目: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have ...