FatMouse' Trade
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 20004Accepted Submission(s): 6223
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 of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* 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.
Input
The 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 J[i] and F[i] respectively. The last test case
is followed by two -1's. All integers are not greater than 1000.
Output
For 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
还是一道贪心算法的题。刚接触贪心,所以趁热打铁继续做几道题。有点晚了 有点累 。
这道题 的思路是,总是先选得到与付出比最大的。
分享到:
相关推荐
杭电hdu acm资料所用杭电的acm题
HDU_ACM培训课件(完整版) HDU_ACM培训课件(完整版) HDU_ACM培训课件(完整版) HDU_ACM培训课件(完整版)
杭电 hdu acm 第1084题的解法,ac过了,是一位学长教我的.内有一些中文说明.
hdu_2102_passed_sorce
此程序为hdu的acm2010题,就是解决水仙花数问题
模式识别_hdu_期末复习资料集合_试卷笔记.zip
HDU_ACM_1002_大数相加C源代码,利用字符串处理
数字图像处理_hdu_期末复习资料_试卷等.zip
数字图像处理总ppt_hdu_许老师.pdf
高级计算机图形学_mm的_重点笔记_hdu_吴xy.pdf
HDU一部分题目原码,大部分是可运行的,可能有几题不完整
B_(HDU_1231)(最大子段和,分治).cpp
杭电acm解题报告 详细解析2000-2099 适合acm初学者
杭电OJ部分答案,可以很简单的解决a+b求和问题及其他问题。
For a positive integer n, let’s denote function f(n,m) as the m-th smallest integer x that x>n and gcd(x,n)=1. For example, f(5,1)=6 and f(5,5)=11. You are given the value of m and (f(n,m)?...
hdu题解的答案十分简单的一个题,思路清晰,特别简单
基础算法类 ACM 入门 杭电OJ 11页题目题解,算法入门的时候刷题可以参考 搜集整理起来了比单个去搜题解方便快捷
hdu 3378 三国杀标程 解题报告
动态规划DP题解 POJ HDU部分动态规划DP题解
里面包含:实验1~8的源代码,ISE软件直接导入就能使用、课件PPT、3份实验报告、实验要求与评分标准。