杭电oj--1009 ( FatMouse' Trade )--贪心算法

博客介绍了杭电oj中的题目‘FatMouse’ Trade,该问题要求计算FatMouse用有限的cat food能获得的最大JavaBeans量。通过贪心策略,根据每个房间的JavaBeans与cat food比例(性价比)进行选择,优先处理性价比高的房间,确保最大化收益。文章提供了两种解题思路,一种是直接计算最高性价比房间,另一种是先对房间数据按性价比排序后再计算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                                      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 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值