【POJ】 1017
来源:互联网 发布:金属探测器软件 编辑:程序博客网 时间:2024/05/17 08:03
http://poj.org/problem?id=1017
有1*1到6*6的物体,求至少需要几个6*6的箱子装它们。
贪心,先装大再装小。这个写的更清楚。
http://www.hankcs.com/program/cpp/poj-1017-packets.html
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <queue>#include <algorithm>using namespace std;int ans;int p1,p2,p3,p4,p5,p6;int s2,s1;int a[4]={0,5,3,1};//一个箱子放入i个3*3后还可以放入几个2*2int main(){ while (cin >> p1 >> p2 >> p3 >> p4 >> p5 >> p6){ if (p1==0&&p2==0&&p3==0&&p4==0&&p5==0&&p6==0){ break; } ans=p4+p5+p6+ceil(p3/4.0); s2=5*p4+a[p3%4]; //【一个箱子放入一个4*4后还可以放5个2*2】+【一个箱子放入(p3%4)个3*3后可以放入x个2*2】,下同。 if (p2>s2){ ans+=ceil((p2-s2)/9.0); } s1=36*ans-36*p6-25*p5-16*p4-9*p3-4*p2; if (p1>s1){ ans+=ceil((p1-s1)/36.0); } cout << ans << endl; }}
阅读全文
0 0
- poj 1017
- POJ-1017
- POJ 1017
- POJ 1017
- poj 1017
- POJ 1017
- poj 1017
- POJ 1017
- poj 1017
- POJ 1017
- poj 1017
- POJ 1017
- poj 1017
- POJ 1017
- poj 1017
- POJ 1017
- 【POJ】 1017
- poj 1017
- Python中文件的读取和写入
- 孙子定理
- boost中circular_buffer存储字符串的使用示例
- html的表格
- Spring
- 【POJ】 1017
- 前端优化网站方法整理
- 理解原型和实例的创建
- html之表单
- css的属性
- HTTP报文讲解和tcp三次握手和四次挥手
- Java面试个人整理(手打勿喷,易于个人学习)3
- vue2.0之axios使用详解
- TypeError: Value passed to parameter 'targets' has DataType float32 not in list of allowed values: i