HDU-1009-肥鼠交易】的更多相关文章

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1009 题目大意:肥鼠准备了 磅的猫粮,准备和看管仓库的猫交易,仓库里装有他最喜爱的食物 豆.仓库有 个房间.第 间房包含了 磅的 豆,需要 磅的猫粮.肥鼠不必为了房间中的所有 豆而交易,相反,他可以支付 % 磅的猫粮去交换得到 % 磅的 豆.这里, 表示一个实数.现在他将这项任务分配给了你:请告诉他,能够获得的 豆的最大值是多少. 题目要求:(输入)输入包含多组测试数据.对于每组测试数据,以包含了两…
题意: 一只老鼠用猫粮来换豆子,每个房间的兑换率不同,所以得尽量从兑换率高的房间先兑换.肥老鼠准备M磅猫粮去跟猫交易,让猫在warehouse中帮他指路,以找到好吃的.warehouse有N个房间,第i个房间包含J[i]磅豆子,且要求F[i]磅猫粮.肥老鼠不必交易房间里的所有豆子,相反,当他以F[i]*a% 磅猫粮交换,就可以拿到J[i]*a%磅豆子,这里a是一个实数.现在,他准备把作业分配给你:他能获得最大的豆子数是多少.输入:非负整数M和N,紧接着有N行,每行有2个正数,分别是J[i]和F[…
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…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1009 FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 93676    Accepted Submission(s): 32566 Problem Description FatMouse prepared M…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1009 FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 92493    Accepted Submission(s): 32082 Problem Description FatMouse prepared M…
FatMouse' Trade 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 requ…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41982    Accepted Submission(s): 13962 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 43381    Accepted Submission(s): 14499 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats gu…
1.因为要排序只派j[i]/f[i],不能知道f[i]和j[i]各自排序后的顺序,因此要用到结构体 2.用sort(ware,ware+n,cmp) cmp 为俩个数组的元素比较大小的布尔值 #include<iostream> #include<algorithm> using namespace std; struct warehouse{ double j,f,p; }; warehouse ware[]; bool cmp(warehouse a,warehouse b)…
题 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] pounds of c…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 36632    Accepted Submission(s): 12064 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats gu…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 42953    Accepted Submission(s): 14336 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
博主英语不好,看懂个大概,老鼠有M磅猫食.有N个房间,每个房间前有一只猫,房间里有老鼠最喜欢的食品JavaBean,J[i].若要引开猫,必须付出相应的猫食F[i]. 当然这只老鼠没必要每次都付出所有的F[i].若它付出F[i]的a%,则得到J[i]的a%.求老鼠能吃到的做多的JavaBean. 解题思路: J[i]/F[i]的比例越大,在这个房间,小鼠付出得到的收获最有价值.于是我们将设置结构体, 结构体里J[i]/F[i].然后对结构体数组进行排序.依次按比例排序的付出猫食,即可. #inc…
B - 贪心 基础 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse contai…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 63198 Accepted Submission(s): 21342 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats guardin…
题意:就是老鼠要用猫粮换粮食,第i个房间一些东西,要用东西去换,可以不全换.问给定的猫粮最多能换多少粮食. 析:贪心算法.我们先算出来每个房间物品的平均价格是多少,肯定越低越好,并且如果能全换就全换,如果不能, 肯定是最后一次了,就把剩下全部换了,看看能换多少.求和. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <v…
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] pounds of cat…
这题是一道简单的可拆分的贪心题目,需要注意的是,我们定义的结构体里面都应该用double类型, 或者float类型,不然两个int相除,就失去了精度(强转也可以). #include <cstdio> #include <algorithm> using namespace std; int m, n; struct Room { double j, f; double k; bool operator < (const Room &b)const { return…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 53352    Accepted Submission(s): 17788 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
解题思路:一只老鼠共有m的猫粮,给出n个房间,每一间房间可以用f[i]的猫粮换取w[i]的豆,问老鼠最多能够获得豆的数量 sum 即每一间房间的豆的单价为v[i]=f[i]/w[i],要想买到最多的豆,一定是先买最便宜的,再买第二便宜的,再买第三便宜的 -----m的值为0的时候求得的sum即为最大值   所以先将v[i]从小到大排序.   FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/…
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/.未经本作者同意不得转载. https://blog.csdn.net/kenden23/article/details/31418535 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favor…
√√第一部分 基础算法(#10023 除外) 第 1 章 贪心算法 √√#10000 「一本通 1.1 例 1」活动安排 √√#10001 「一本通 1.1 例 2」种树 √√#10002 「一本通 1.1 例 3」喷水装置 √√#10003 「一本通 1.1 例 4」加工生产调度 √√#10004 「一本通 1.1 例 5」智力大冲浪 √√#10005 「一本通 1.1 练习 1」数列极差 √√#10006 「一本通 1.1 练习 2」数列分段 √√#10007 「一本通 1.1 练习 3」线…
HDU - 1009 https://paste.ubuntu.com/p/rgSYpSKkwW/ POJ - 1017 麻烦的模拟 贪心 题意就是用尽量少的66h箱子装nnh的物品,贪心策略很明显,就是写着特麻烦.. https://paste.ubuntu.com/p/rjfkMNPjtB/ POJ - 2231 曼哈顿距离 前缀和 题意:给定数列\(a_1,a_2,...a_n\),求\(\sum_{i=1}^{n}\sum_{j=1}^{n}|a_i-a_j|\),n范围1e4 排序后消…
度度熊的交易计划 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1111    Accepted Submission(s): 403 Problem Description 度度熊参与了喵哈哈村的商业大会,但是这次商业大会遇到了一个难题: 喵哈哈村以及周围的村庄可以看做是一共由n个片区,m条公路组成的地区. 由于生产能力的区别,第i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意:给定一个图(n个顶点m条边),求其补图最短路 思路:集合a表示当前还未寻找到的点,集合b表示本次bfs之后仍未寻找到的点 #include<cstdio> #include<set> #include<queue> #include<cstring> using namespace std; const int N = 2e5 + 5; set &l…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4714 Tree2cycle Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 400    Accepted Submission(s): 78 Problem Description A tree with N nodes and N-…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=6394 思路:用dfs序处理下树,在用分块,我们只需要维护当前这个点要跳出这个块需要的步数和他跳出这个块去到的下一个点的下标,这样更新和询问的复杂度就降到了sqrt(n),查询树上的点的时候我们可以用倍增来降时间复杂度,这样处理下就不会超时了,. 介绍下代码主要数组的作用方便看懂代码:l[i] : 当前块的左边界 r[i]:当前块的右边界 num[i]: 当前点需要多少步跳出这个块 pre[i]: 这个…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4767 题意:求集合{1, 2, 3, ..., n}有多少种划分情况bell[n],最后结果bell[n] mod 95041567. 分析:首先了解三个概念:贝尔数   第二类斯特灵数   中国剩余定理 贝尔数是指基数为n的集合的划分方法的数目. 贝尔数适合递推公式: 每个贝尔数都是"第二类Stirling数"的和 贝尔数满足两个公式:(p为质数)             1) B[n+…
度度熊的交易计划 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1192    Accepted Submission(s): 440 Problem Description 度度熊参与了喵哈哈村的商业大会,但是这次商业大会遇到了一个难题: 喵哈哈村以及周围的村庄可以看做是一共由n个片区,m条公路组成的地区. 由于生产能力的区别,第i…
Gems Fight! Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others)Total Submission(s): 114    Accepted Submission(s): 46 Problem Description Alice and Bob are playing "Gems Fight!": There are Gems of G different…