ImageVerifierCode 换一换
格式:DOCX , 页数:9 ,大小:27.74KB ,
资源ID:7125912      下载积分:10 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.docduoduo.com/d-7125912.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(贪心算法习题.docx)为本站会员(fmgc7290)主动上传,道客多多仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知道客多多(发送邮件至docduoduo@163.com或直接QQ联系客服),我们立即给予删除!

贪心算法习题.docx

1、喷水装置(一)时间限制: 3000 ms | 内存限制:65535 KB难度:3描述现有一块草坪,长为 20 米,宽为 2 米,要在横中心线上放置半径为 Ri 的喷水装置,每个喷水装置的效果都会让以它为中心的半径为实数 Ri(0= 0 ), is known. Each 5 minutes of fishing decreases the number of fish expected to be caught in the next 5-minute interval by a constant rate of di (di = 0). If the number of fish expec

2、ted to be caught in an interval is less than or equal to di , there will be no more fish left in the lake in the next interval. To simplify the planning, John assumes that no one else will be fishing at the lakes to affect the number of fish he expects to catch. Write a program to help John plan his

3、 fishing trip to maximize the number of fish expected to be caught. The number of minutes spent at each lake must be a multiple of 5. 输入You will be given a number of cases in the input. Each case starts with a line containing n. This is followed by a line containing h. Next, there is a line of n int

4、egers specifying fi (1 = i =n), then a line of n integers di (1 =i =n), and finally, a line of n - 1 integers ti (1 =i =n - 1). Input is terminated by a case in which n = 0. 输出For each test case, print the number of minutes spent at each lake, separated by commas, for the plan achieving the maximum

5、number of fish expected to be caught (you should print the entire plan on one line even if it exceeds 80 characters). This is followed by a line containing the number of fish expected. If multiple plans exist, choose the one that spends as long as possible at lake 1, even if no fish are expected to

6、be caught in some intervals. If there is still a tie, choose the one that spends as long as possible at lake 2, and so on. Insert a blank line between cases. 样例输入2 1 10 1 2 5 2 4 4 10 15 20 17 0 3 4 3 1 2 3 4 4 10 15 50 30 0 3 4 3 1 2 3 0 样例输出45, 5 Number of fish expected: 31 240, 0, 0, 0 Number of

7、fish expected: 480 115, 10, 50, 35 Number of fish expected: 724 过河问题时间限制: 1000 ms | 内存限制:65535 KB难度:5描述在漆黑的夜里,N 位旅行者来到了一座狭窄而且没有护栏的桥边。如果不借助手电筒的话,大家是无论如何也不敢过桥去的。不幸的是,N 个人一共只带了一只手电筒,而桥窄得只够让两个人同时过。如果各自单独过桥的话,N 人所需要的时间已知;而如果两人同时过桥,所需要的时间就是走得比较慢的那个人单独行动时所需的时间。问题是,如何设计一个方案,让这 N 人尽快过桥。 输入第一行是一个整数 T(1=T=20)表

8、示测试数据的组数每组测试数据的第一行是一个整数 N(1=N=1000)表示共有 N 个人要过河每组测试数据的第二行是 N 个整数 Si,表示此人过河所需要花时间。(0Si=100)输出输出所有人都过河需要用的最少时间样例输入141 2 5 10样例输出17心急的 C 小加时间限制: 1000 ms | 内存限制:65535 KB难度:4描述C 小加有一些木棒,它们的长度和质量都已经知道,需要一个机器处理这些木棒,机器开启的时候需要耗费一个单位的时间,如果第 i+1 个木棒的重量和长度都大于等于第 i 个处理的木棒,那么将不会耗费时间,否则需要消耗一个单位的时间。因为急着去约会,C 小加想在最短

9、的时间内把木棒处理完,你能告诉他应该怎样做吗?输入第一行是一个整数 T(1T1500),表示输入数据一共有 T 组。每组测试数据的第一行是一个整数 N(1=N=5000 ),表示有 N 个木棒。接下来的一行分别输入 N 个木棒的 L,W(0 L ,W = 10000),用一个空格隔开,分别表示木棒的长度和质量。输出处理这些木棒的最短时间。样例输入3 5 4 9 5 2 2 1 3 5 1 4 3 2 2 1 1 2 2 3 1 3 2 2 3 1 样例输出213BUYING FEED时间限制: 3000 ms | 内存限制:65535 KB难度:4描述Farmer John needs to

10、travel to town to pick up K (1 = K = 100)pounds of feed. Driving D miles with K pounds of feed in his truck costs D*K cents.The county feed lot has N (1 = N= 100) stores (conveniently numbered 1N) that sell feed. Each store is located on a segment of the X axis whose length is E (1 = E = 350). Store

11、 i is at location X_i (0 X_i E) on the number line and can sell John as much as F_i (1 = F_i = 100) pounds of feed at a cost of C_i (1 = C_i = 1,000,000) cents per pound.Amazingly, a given point on the X axis might have more than one store.Farmer John starts at location 0 on this number line and can

12、 drive only in the positive direction, ultimately arriving at location E, with at least K pounds of feed. He can stop at any of the feed stores along the way and buy any amount of feed up to the the stores limit. What is the minimum amount Farmer John has to pay to buy and transport the K pounds of

13、feed? Farmer Johnknows there is a solution. Consider a sample where Farmer John needs two pounds of feed from three stores (locations: 1, 3, and 4) on a number line whose range is 05: 0 1 2 3 4 5 - 1 1 1 Available pounds of feed 1 2 2 Cents per poundIt is best for John to buy one pound of feed from

14、both the second and third stores. He must pay two cents to buy each pound of feed for a total cost of 4. When John travels from 3 to 4 he is moving 1 unit of length and he has 1 pound of feed so he must pay1*1 = 1 cents.When John travels from 4 to 5 heis moving one unit and he has 2 pounds of feed s

15、o he must pay 1*2 = 2 cents. The total cost is 4+1+2 = 7 cents.输入The first line of input contains a number c giving the number of cases that followThere are multi test cases ending with EOF.Each case starts with a line containing three space-separated integers: K, E, and NThen N lines follow :every

16、line contains three space-separated integers: Xi Fi Ci输出For each case,Output A single integer that is the minimum cost for FJ to buy and transport the feed样例输入12 5 3 3 1 24 1 21 1 1样例输出7疯牛时间限制: 1000 ms | 内存限制:65535 KB难度:4描述农夫 John 建造了一座很长的畜栏,它包括 N (2 = N = 100,000)个隔间,这些小隔间依次编号为 x1,.,xN (0 = xi = 1,

17、000,000,000).但是,John 的 C (2 = C = N)头牛们并不喜欢这种布局,而且几头牛放在一个隔间里,他们就要发生争斗。为了不让牛互相伤害。John 决定自己给牛分配隔间,使任意两头牛之间的最小距离尽可能的大,那么,这个最大的最小距离是什么呢?输入有多组测试数据,以 EOF 结束。第一行:空格分隔的两个整数 N 和 C第二行 第 N+1 行:分别指出了 xi 的位置输出每组测试数据输出一个整数,满足题意的最大的最小值,注意换行。样例输入5 312849样例输出3Yougth 的最大化时间限制: 1000 ms | 内存限制:65535 KB难度:4描述Yougth 现在有 n 个物品的重量和价值分别是 Wi 和 Vi,你能帮他从中选出 k 个物品使得单位重量的价值最大吗?输入有多组测试数据每组测试数据第一行有两个数 n 和 k,接下来一行有 n 个数 Wi 和 Vi。(1=k=n=10000) (1=Wi,Vi=1000000)输出输出使得单位价值的最大值。(保留两位小数)样例输入3 22 25 32 1样例输出0.75

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报