Poj 1017 Packets(贪心策略)】的更多相关文章

一.题目大意: 一个工厂生产的产品用正方形的包裹打包,包裹有相同的高度h和1*1, 2*2, 3*3, 4*4, 5*5, 6*6的尺寸.这些产品经常以产品同样的高度h和6*6的尺寸包袱包装起来运送给客户.工厂和客户最关心的就是尽量使用少的包裹来运送客户定的产品以减少费用.一个能计算运送产品所需最少包裹的程序能节约很多钱.你的任务就是编写这个程序. 输入: 输入文件包含若干行订单,每行表示一个订单.一个订单包含六个整数,用空格分开,表示产品尺寸对应的包裹个数,从最小尺寸1*1,到最大尺寸6*6,…
题意:所有货物的高度一样,且其底面积只有六种,分别为1*1 2*2 3*3 4*4 5*5 6*6的,货物的个数依次为p1,p2,p3,p4,p5,p6, 包裹的高度与货物一样,且底面积就为6*6,然后求最少要多少个包裹包含以上所有货物 思路: 由于高度一样,所以忽略高度,只用讨论底面积. 分类讨论: 底面积为6*6的货物,需要1个包裹 底面积为5*5的货物,需要1个包裹,剩余空间用1*1货物填充 底面积为4*4的货物,需要1个包裹,剩余空间用2*2 / 1*1货物填充 底面积为3*3的货物,每…
POJ 1017 题意: 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为 1*1, 2*2, 3*3, 4*4, 5*5, 6*6.  这些产品通常使用一个  6*6*h的长方体包裹包装然后邮寄给客户.因为邮费很贵,所以工厂要想方设法的减小每个订单运送时的包裹数量.他们很需要有一个好的程序帮他们解决这个问题从而节省费用.现在这个程序由你来设计.输入数据输入文件包括几行,每一行代表一个订单.每个订单里的一行包括六个整数,中间用空格隔开,分别为 1…
Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43189   Accepted: 14550 Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are alway…
Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 48349   Accepted: 16392 Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are alway…
[题意简述]:这个是别人的博客,有清晰的题意描写叙述.和解题思路,借助他的想法,能够非常好的解决问题! [分析]:贪心?模拟?见代码 //216K 16Ms #include<iostream> using namespace std; int main() { int ans,a,b,c,d,e,f,Two,One;// 当中Two表示2*2的个数.同理One表示1*1的个数. int u[4] = {0,5,3,1}; while(1) { cin>>a>>b>…
Packets Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcels of the same height h as the products h…
题意:有一些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> #inc…
http://poj.org/problem?id=3614 有c头奶牛在沙滩上晒太阳,每头奶牛能忍受的阳光强度有一个最大值(max_spf) 和最小值(min_spf),奶牛有L种防晒霜,每种可以固定阳光强度在某一个值,每种的数量是cover[i] ,每头奶牛只能用一瓶防晒霜,问最多有多少头奶牛能在沙滩上晒太阳. 理解题意之后还是挺好做的. 首先确定的贪心策略是,在满足min_spf的条件下,尽量用spf小的用在max_spf大的奶牛身上,用一个最小堆维护max_spf的最小值即可. 先对奶牛…
地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪枝 然而 还是TLE了 TLE代码 #include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; vector<pair&l…
Best Time to Buy and Sell Stock Total Accepted: 14044 Total Submissions: 45572My Submissions Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, b…
https://vjudge.net/problem/POJ-1328 贪心策略选错了恐怕就完了吧.. 一开始单纯地把island排序,然后想从左到右不断更新,其实这是错的...因为空中是个圆弧. 后来知道了通过对每个island求雷达范围,将这些范围排序,但是去重策略也没想对.因为有两种情况,都需要更新t值,但是只有一种需要ans++. #include<iostream> #include<cstdio> #include<queue> #include<cs…
问题 H: 越野跑[贪心策略] [题面] 为了能在下一次跑步比赛中有好的发挥,贝茜在一条山路上开始了她的训练.贝茜希望能在每次训练中跑得尽可能远,不过她也知道农场中的一条规定:奶牛独自进山的时间不得超过M秒(1< =M< =10,000,000). 整条山路被贝茜划分成T个长度相同的小段(1< = T< = 100,000),并且,贝茜用S_i表示第i个小段的路况.S_i为u,f,d这3个字母之一,它们分别表示 第i个小段是上坡.平地,或是下坡. 贝茜要花U秒(1< =U&l…
一.题目信息 The - Modcrab 简单翻译一下:Vova有生命值h1,每次攻击值为a1,每瓶药水恢复生命值c1;Modcrab有生命值h2,每次攻击值为a2.在每个关卡开始,Vova有两种选择,要么攻击怪兽Modcrab,要么喝一瓶药水(Modcrab的生命值允许超过h2),然后,如果战斗没有结束,Modcrab会攻击Vova.战斗结束的标志是Vova(或Modcrab)的生命值降至0,或者更低. 注:1.选择喝药水,Modcrab也会攻击Vova.2.攻击是有先后顺序的 二.算法描述…
众所周知lyb根本不学习.但是期末到了,平时不写作业的他现在有很多作业要做. CUC的老师很严格,每个老师都会给他一个DDL(deadline). 如果lyb在DDL后交作业,老师就会扣他的分. 现在假设lyb做作业都需要一天. 所以lyb想到要安排做作业的顺序,这样才能尽可能扣少一点分. 请帮帮bx吧. Input 输入包含T个测试用例.输入的第一行是单个整数T,为测试用例的数量. 每个测试用例以一个正整数N开头(1<=N<=1000),表示作业的数量. 然后两行.第一行包含N个整数,表示D…
Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 59725   Accepted: 20273 Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are alway…
1.链接地址: http://poj.org/problem?id=1017 http://bailian.openjudge.cn/practice/1017 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为1*1, 2*2, 3*3, 4*4, 5*5, 6*6.这些产品通常使用一个 6*6*h 的长方体包裹包装然后邮寄给客户.因为邮费很贵,所以工厂要想方设法的减小每个…
Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcels of the same height h as the products have and…
装箱问题1.0 题目大意:就是一个工厂制造的产品都是正方形的,有1*1,2*2,3*3,4*4,5*5,6*6,高度都是h,现在要包装这些物品,只能用6*6*h的包装去装,问你怎么装才能使箱子打到最小? 这一题其实很简单,装箱子问题一般都是贪婪算法,这一题也不例外,那么这一又要怎么贪心呢?其实可以这样,我们可以看到,如果我们装了6,5,4这三个尺寸的物品,那么这个一个箱子肯定只能最大装这三个物品一个,6尺寸箱子没有空余位置,5尺寸的箱子还有11个空位,可以装11个1尺寸的物品,4尺寸的箱子可以再…
Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 47513   Accepted: 16099 Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are alway…
题意:有1*1到6*6的的东西,需要用6*6的箱子将它们装起来.问:至少需要多少个6*6箱子 思路: 一个瓶子怎么装东西最多?先装石头,在装沙子,然后装水. 同样放在本题就是先装6*6然后5*5..... 想法上的一些解释:(如何装呢) 6*6物品n件,需要箱子n个 5*5物品n件,需要箱子n个,剩下 36n-25n个1*1的空余 4*4物品n件,需要箱子n个,剩下5n个2*2的空余,1*1也有也有空余 3*3物品n件,需要箱子(n+3)/4个(向上取余),如果只装1个3*3的箱子剩下5个2*2…
http://poj.org/problem?id=1017 有1*1 2*2...6*6的物品 要装在 6*6的parcel中 问最少用多少个parcel 一直没有找到贪心的策略 问题应该出现在 总是在想怎么放入parcel中 使得最节省空间 其实这种角度是很麻烦的 情况太多 很难描述清楚 但是其实 放一类型物品 得到的结果是非常具体的 -->>>即从要放的东西的角度出发 放 一个6*6 物品 会占用一个parce 放 一个5*5 物品 会占用一个parce 并且空出11个1*1的空位…
#include <string.h> #include <iostream> #include <queue> #include <stdio.h> using namespace std; struct product{ int deadline; int val; friend bool operator<(product n1,product n2) { return n1.val<n2.val; } }q; ]; int main()…
http://poj.org/problem?id=1017 题意就是有6种规格的物品,给你一些不同规格的物品,要求你装在盒子里,盒子是固定尺寸的也就是6*6,而物品有1*1,2*2,3*3,4*4,5*5,6*6,给定你一些物品的数量,求最少的盒子的用量. 思路:对于大的盒子先放,而小的盒子,如果可以填充的话,就填充,也是又大到小填充.分析多种情况即可 #include <stdio.h> #include <iostream> using namespace std; int…
题目链接: http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MSMemory Limit: 65536K 问题描述 to avoid unsightly burns while tanning, each of the c (1 ≤ c ≤ 2500) cows must cover her hide with sunscreen when they're at the beach. cow i has a minimum and…
简单的说说思路,如果一开始能够去到目的地那么当然不需要加油,否则肯定选择能够够着的油量最大的加油站加油,,不断重复这个贪心的策略即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> using namespace std; const int maxn=1e4+9; int dist,p,n; struc…
题意:有6种箱子,1x1 2x2 3x3 4x4 5x5 6x6,已知每种箱子的数量,要用6x6的箱子把全部箱子都装进去,问需要几个. 一开始以为能箱子套箱子,原来不是... 装箱规则:可以把箱子都看成正方体,装在6x6的盒子里. 典型的贪心题. 思路:(参考了Starginer大神的) ①每个6*6的都占一个箱子. ②每个5*5的放在一个箱子里,同时里面还能装11个1*1的. ③每个4*4的放在一个箱子里,同时里面还能装5个2*2的,如果2*2的不够了,那么还能放1*1的. ④每4个3*3的放…
题目链接:http://poj.org/problem?id=1456 Time Limit: 2000MS Memory Limit: 65536K Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of tim…
Bridge over a rough river Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4143   Accepted: 1703 Description A group of N travelers (1 ≤ N ≤ 50) has approached an old and shabby bridge and wishes to cross the river as soon as possible. Ho…
Tian Ji -- The Horse Racing Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 12490   Accepted: 3858 Description Here is a famous story in Chinese history. That was about 2300 years ago. General Tian Ji was a high official in the country Q…