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 Jii pounds of JavaBeans and requires Fii pounds of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get Jii* a% pounds of JavaBeans if he pays Fii* a% pounds of cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain. 

InputThe input consists of multiple test cases. Each test case begins with a line containing two non-negative integers M and N. Then N lines follow, each contains two non-negative integers Jii and Fii respectively. The last test case is followed by two -1's. All integers are not greater than 1000. 
OutputFor each test case, print in a single line a real number accurate up to 3 decimal places, which is the maximum amount of JavaBeans that FatMouse can obtain. 
Sample Input

5 3
7 2
4 3
5 2
20 3
25 18
24 15
15 10
-1 -1

Sample Output

13.333
31.500

HDU1009:FatMouse' Trade(初探贪心,wait)的更多相关文章

  1. HDU1009 FatMouse' Trade

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. hdu 1009:FatMouse' Trade(贪心)

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. HDU 1009 FatMouse' Trade【贪心】

    解题思路:一只老鼠共有m的猫粮,给出n个房间,每一间房间可以用f[i]的猫粮换取w[i]的豆,问老鼠最多能够获得豆的数量 sum 即每一间房间的豆的单价为v[i]=f[i]/w[i],要想买到最多的豆 ...

  4. [题解]hdu 1009 FatMouse' Trade(贪心基础题)

    Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding th ...

  5. 杭电 1009 FatMouse' Trade (贪心)

    Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding th ...

  6. HDU 1009 FatMouse' Trade (贪心算法)

    题意:就是老鼠要用猫粮换粮食,第i个房间一些东西,要用东西去换,可以不全换.问给定的猫粮最多能换多少粮食. 析:贪心算法.我们先算出来每个房间物品的平均价格是多少,肯定越低越好,并且如果能全换就全换, ...

  7. HDU 1009 FatMouse' Trade (贪心)

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1009 题目大意:肥鼠准备了 磅的猫粮,准备和看管仓库的猫交易,仓库里装有他最喜爱的食物 豆.仓库有 个 ...

  8. HDU 1009 FatMouse' Trade(贪心)

    FatMouse' Trade Problem Description FatMouse prepared M pounds of cat food, ready to trade with the ...

  9. HDU 1009 FatMouse' Trade(简单贪心 物品可分割的背包问题)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1009 FatMouse' Trade Time Limit: 2000/1000 MS (Java/O ...

随机推荐

  1. Python 装饰器和抽象类

    #装饰器:对类或者函数进行功能的扩展 ''' #第一步:基本函数 def la(): print('脚踏黄河两岸,手拿机密文件,前面机枪扫射,后面炮火连天') #调用函数 la() la() #第二步 ...

  2. 【算法】最小乘积生成树 & 最小乘积匹配 (HNOI2014画框)

    今天考试的时候果然题目太难于是我就放弃了……转而学习了一下最小乘积生成树. 最小乘积生成树定义: (摘自网上一篇博文). 我们主要解决的问题就是当k = 2时,如何获得最小的权值乘积.我们注意到一张图 ...

  3. [BZOJ 2438] [中山市选2011]杀人游戏 Tarjan缩点

    这个题很容易想到正解就是缩点找入度为零的点,那么我们考虑一种特殊情况就是,一个入度为零的点我们不访问他就知道他是不是凶手,那么这样的话就是:I. 他是一个真·孤立的点 II. 他在图里但是在他的强联通 ...

  4. nc用法小记

    By francis_hao    Jun 30,2017   ncat:连接和重定向套接字 概要 ncat [OPTIONS...] [hostname] [port]   描述 ncat 是一个集 ...

  5. lwIP RAW_API

    lwIP RAW TCP/IP接口 作者: Adam Dunkels, Leon Woestenberg, Christiaan Simons lwIP为使用TCP/IP协议通信的应用程序编程提供了两 ...

  6. Spring学习--通过注解配置 Bean (二)

    在 classpath 中扫描组件: 当在组件类上使用了特定的注解之后 , 还需要在 Spring 的配置文件中声明 <context:component-scan>: base-pack ...

  7. Java基础学习知识体系图

  8. HDU3790---(双权最短路径)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3790 最短路径问题 Time Limit: 2000/1000 MS (Java/Others)    M ...

  9. RPC-Thrift(一)

    一个简单例子 IDL文件如下,详细的IDL语法参考官方文档http://thrift.apache.org/docs/idl. 通过代码生成工具得到两个文件:HelloService.java和Res ...

  10. Bzoj1692 洛谷P2870 [Usaco2007 Dec]队列变换

    Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1570  Solved: 656 Description FJ打算带他的N(1 <= N <= ...