FatMouse' Trade(Hdu 1009)】的更多相关文章

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…
传送门: 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 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…
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…
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): 63198 Accepted Submission(s): 21342 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats guardin…
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): 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/…
FatMouse' Trade 点我挑战题目 题意分析 每组数据,给出有的猫粮m与房间数n,接着有n行,分别是这个房间存放的食物和所需要的猫粮.求这组数据能保证的最大的食物是多少? (可以不完全保证这个房间的食物,及食物和猫粮可以同时乘a%) 经典的贪心策略. 先保证性价比最高的房间(花较少的猫粮可以保证最多的粮食),每组数据计算一个比率rate = 房间存放的粮食/所需要的猫粮,按照rate对其进行降序排列,优先满足上方的房间即可. 代码纵览 /* Title:HDOJ.1009 Author…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 45213    Accepted Submission(s): 15137 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats gu…
/* problem: FatMouse' Trade this is greedy problem. firstly:we should calculate the average J[i]/F[i] and sort it secondly: according to the m and choose the most high ones */ #include<iostream> #include<vector> #include<algorithm> using…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 33703    Accepted Submission(s): 10981 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
FatMouse' Trade 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…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 103515    Accepted Submission(s): 36159 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
FatMouse' Trade Time Limit: 2 Seconds      Memory Limit: 65536 KB 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…
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…
题 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…
题意: 一只老鼠用猫粮来换豆子,每个房间的兑换率不同,所以得尽量从兑换率高的房间先兑换.肥老鼠准备M磅猫粮去跟猫交易,让猫在warehouse中帮他指路,以找到好吃的.warehouse有N个房间,第i个房间包含J[i]磅豆子,且要求F[i]磅猫粮.肥老鼠不必交易房间里的所有豆子,相反,当他以F[i]*a% 磅猫粮交换,就可以拿到J[i]*a%磅豆子,这里a是一个实数.现在,他准备把作业分配给你:他能获得最大的豆子数是多少.输入:非负整数M和N,紧接着有N行,每行有2个正数,分别是J[i]和F[…
版权声明:本文作者靖心,靖空间地址: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…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1009 题目大意:肥鼠准备了 磅的猫粮,准备和看管仓库的猫交易,仓库里装有他最喜爱的食物 豆.仓库有 个房间.第 间房包含了 磅的 豆,需要 磅的猫粮.肥鼠不必为了房间中的所有 豆而交易,相反,他可以支付 % 磅的猫粮去交换得到 % 磅的 豆.这里, 表示一个实数.现在他将这项任务分配给了你:请告诉他,能够获得的 豆的最大值是多少. 题目要求:(输入)输入包含多组测试数据.对于每组测试数据,以包含了两…
题意:就是老鼠要用猫粮换粮食,第i个房间一些东西,要用东西去换,可以不全换.问给定的猫粮最多能换多少粮食. 析:贪心算法.我们先算出来每个房间物品的平均价格是多少,肯定越低越好,并且如果能全换就全换,如果不能, 肯定是最后一次了,就把剩下全部换了,看看能换多少.求和. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <v…
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…
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] pounds…
这道题目是一道非常简单的贪心,但是我却修改了1h+.原因就是qsort的comp有bug.其实还是题目中的数据可以为0.除数为0真的要慎重啊.后来改为结构体,加一层循环选取最大值,果然ac啊.wa了几次,测试数据都过,还是wa.无语.这道题目一定要注意数据类型,double型. #include <stdio.h> #include <stdlib.h> #define MAXNUM 10050 typedef struct { int js, fs; double rate; }…
Tips:本题采用贪心算法,类似于背包问题,关键在于读入数据之后,将数据按 J[i]/F[i] 从大到小排列即可. /**本程序主要采用贪心算法思想,类似于背包问题*/ #include<stdio.h> #include<string.h> int main() { int M,N; while(scanf("%d %d",&M,&N)) { && N == -) { ; } ]={},F[]={}; double sum =…
贪心的运用,主要看其比值,取最大值实现贪心... #include<cstdio> #include<algorithm> #include<vector> using namespace std; struct room { int j; int f; bool operator < (const room t)const { return (float)j/f >(float)t.j/t.f; } }; int main() { //freopen(&q…
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…