HDU 4803 Poor Warehouse Keeper(贪心)】的更多相关文章

版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/26005267 题目链接:hdu 4803 Poor Warehouse Keeper 题目大意:有以个屏幕能够显示两个值,一个是数量x,一个是总价y. 有两种操作.一种是加一次总价,变成x,x+y:一种是加一个数量,这要的话总价也会对应加上一个的价钱.变成x+1.y+y/x.总价显示的为取整后的整数,小数部分忽略. 给定一个目标x.y.初始状…
题目链接 题意 :屏幕可以显示两个值,一个是数量x,一个是总价y.有两种操作,一种是加一次总价,变成x,1+y:一种是加一个数量,这要的话总价也会相应加上一个的价钱,变成x+1,y+y/x.总价显示的为取整后的整数,小数部分忽略.给定一个目标x,y,初始状态为1,1,求最少需要多少次可以目标状态,不可以达到的话输出-1. 思路 :如果是加一次总价的话,单价就在变大:如果是加一次数量的话,单价是不变的.因此,单价只涨不降.物品的数量也必须从1变成x,也就是说至少要加x-1次单价才可以,那么如果单价…
555555,能避开精度还是避开精度吧,,,,我们是弱菜.. Poor Warehouse Keeper Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1672    Accepted Submission(s): 463 Problem Description Jenny is a warehouse keeper. He writ…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4803 解题报告:有一个记录器,一共有两个按钮,还有两行屏幕显示,第一行的屏幕显示的是数目,第二行的屏幕显示的是总价,按第一行的按钮表示单价不变,数量加1,同时第二行的总价会根据当前的单价进行相应的增加,然后按一下第二行的按钮表示数量不变,总价加1,这样的话单价就变大了.现在给出这个屏幕上显示的初始的第一行的是1,第二行的是1,然后再给出结束的时候第一行是x,第二行是y,让你求要从初始的变成最后的至少…
题意: 给出x,y两个值分别代表x个物品,总价为y 有两种变化: 1.使总价+1,数量不变 2.数量+1,总价跟着变化 (y = y + y / x) 思路: 给出目标x,y,计算最少变化次使数量变化的只有一种,所以至少需要x-1次变化. 每次增多数量的时候,先把单价提高到目标单价.(这样才会是最优解) 对于每一次增高单价,我们可以用 (int)(当前数量 * 目标单价 - 当前总价) 得到差值,这个差值,即变化的次数,因为一次变化1. 因为用了强转,所以会有精度问题,就是说我们在前面吧当前的单…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4803 Problem Description Jenny is a warehouse keeper. He writes down the entry records everyday. The record is shown on a screen, as follow:There are only two buttons on the screen. Pressing the button i…
Poor Warehouse Keeper http://acm.hdu.edu.cn/showproblem.php?pid=4803 Jenny is a warehouse keeper. He writes down the entry records everyday. The record is shown on a screen, as follow: There are only two buttons on the screen. Pressing the button in…
HDU 4957 Poor Mitsui pid=4957" style="">题目链接 思路:利用相邻交换法去贪心就可以.注意容积为0的情况,这是个坑点 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 45; struct SB { int a, b; } sb[N]; bool cmp(…
题意:一开始有1个物品,总价是1.你的一次操作可以要么使得物品数量+1,总价加上当前物品的单价.要么可以使得总价+1,物品数量不变.问你最少要几次操作从初始状态到达有x个物品,总价是y的状态.这里的y可以有小数点后的部分,会抹去. 如果x>y,显然无解. 因为不管怎样操作,物品的单价是单调不下降的.所以一个naive的贪心策略是先用第二种操作,将物品提升到最大的可能单价(<(y+1)/x),然后再用第一种操作操作到不能再操作为止,剩余的部分用第二种补齐.然而这是不对的. 我们发现,第一种操作,…
A.GPA(HDU4802): 给你一些字符串对应的权重,求加权平均,如果是N,P不计入统计 GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1193    Accepted Submission(s): 743 Problem Description In college, a student may take several…
hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define CLR(a,b) memset((a),(b),sizeof(…
Warehouse Keeper Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 260164-bit integer IO format: %lld      Java class name: Main Special Judge   The company where Jerry works owns a number of warehouses that ca…
http://acm.hdu.edu.cn/showproblem.php?pid=4803 话说C++还卡精度么?  G++  AC  C++ WA 我自己的贪心策略错了 -- 就是尽量下键,然后上键,最后下键补全,可是例子都过不了..... 题解參考http://www.cnblogs.com/xuesu/p/3967704.html http://www.cnblogs.com/Canon-CSU/p/3451784.html http://blog.csdn.net/keshuai199…
尽可能的让当前的平均值接近最后的平均值才能最快达到终点的情况 #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { // freopen("a.in" , "r" , stdin); int x , y; ) { if(y<x){ puts("-1"); continue; }…
Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pound…
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even musicology as background. And now in this prob…
Windows 10 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5802 Description Long long ago, there was an old monk living on the top of a mountain. Recently, our old monk found the operating system of his computer was updating to windows 10 automatical…
Reorder the Books Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5500 Description dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n≤19)n(n\leq 19)n(n≤19)本,每本书有一个编号,从111号到nnn号. dxy把这些书按编号从小到大,从上往下摞成一摞.dxy对这套书极其重视,不允许…
Four Operations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 22    Accepted Submission(s): 12 Problem Description Little Ruins is a studious boy, recently he learned the four operations!Now h…
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Problem Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5281 贪心题目,但是看看我的博客里边相关贪心的题解实在是少的可怜,这里就写出来供大家一起探讨. 题意还是比较好理解的,这里有一个小小的坑点:枪的数量,和怪物的数量,不一定是相等的,所以我们这里要特殊处理一下. reverse函数:http://blog.sina.com.cn/s/blog_6d79d83a0100wh95.html #include <stdio.h> #include <…
第一题;http://acm.hdu.edu.cn/showproblem.php?pid=1257 贪心与dp傻傻分不清楚,把每一个系统的最小值存起来比较 #include<cstdio> using namespace std; ],b[]; int main() { int n,i,j; while (~scanf("%d",&n)) { ; b[]=-; ;i<n;i++) { scanf("%d",&a[i]); ;j&l…
http://acm.hdu.edu.cn/showproblem.php?pid=5073 就是给你 n 个数,代表n个星球的位置,每一个星球的重量都为 1 开始的时候每一个星球都绕着质心转动,那么质心的位置就是所有的星球的位置之和 / 星球的个数 现在让你移动 k 个星球到任意位置(多个星球可以在同一个位置并且所有的星球在同一直线上) 移动之后那么它们质心的位置就可能发生变化,求 I = sum(di^2) (di表示第i个星球到达质心的距离)最小 根据方差的性质(越密越小)得知贪心策略就是…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 /*Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7903 Accepted Submission(s): 4680 Problem Description Ignatius has just c…
Divide the Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5783 Description Alice has a sequence A, She wants to split A into as much as possible continuous subsequences, satisfying that for each subsequence, every its prefix sum is not smal…
Keep On Movin 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5744 Description Professor Zhang has kinds of characters and the quantity of the i-th character is ai. Professor Zhang wants to use all the characters build several palindromic strings. He…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem DescriptionIgnatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Eve…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5661 bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=686&pid=1002 题解: 考虑从高位到低位贪心,对于每一位, (1).如果x,y只有唯一的取法,那么只能这么取:否则贪心地必须使答案的这一位等于1. (2).如果x,y都是0,1都能取,则设这是从右向左数第len位,因为x,y能…
Break the Chocolate Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4112 Description Benjamin is going to host a party for his big promotion coming up.Every party needs candies, chocolates and beer, and of cour…
Poor Akagi Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 131    Accepted Submission(s): 29 Problem Description Akagi is not only good at basketball but also good at math. Recently, he got a…