一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 685|回复: 4
收起左侧

[找工就业] Coursera OA Metals 求大神解题-格式贴

[复制链接] |试试Instant~ |关注本帖
bcc 发表于 2016-10-4 07:28:15 | 显示全部楼层 |阅读模式

2016(10-12月)-[14]CE硕士+<3个月短暂实习/全职 - 校园招聘会| 码农类全职@Courserafresh grad应届毕业生

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x
Mr. Octopus has recently shut down hisfactory and want to sell off his metal rods to a local businessman.
In order to maximize profit, he should sellthe metal of same size and shape. If he sells  metal rods of length ,he receives N x L xmetal_price. The remaining smallermetal rods will be thrown away. To cut the metal rods, he needs to pay cost_per_cut for every cut.
What is the maximum amount of money Mr.Octopus can make?
Input Format
First line of input contains cost_per_cut
Second line of input contains metal_price
Third line contains L, the number of rods Mr. Octopus has,followed by L integers in each line representinglength of each rod.
Output Format
Print the result corresponding to the testcase.
Constraints
1 <= metal_price, cost_per_cut <= 1000
1 <= L <= 50
Each element of lenghts will lie in range [1, 10000].
Sample Input#00
1
10
3
26
103
59
Sample Output#00
1770
Explanation Here cuts are pretty cheap. So we can make largenumber of cuts to reduce the amount of wood wasted. Most optimal lengths ofrods will be . So we will cut  pieces of length  from  rod,and throw peice of length  from it. Similarly we will cut  piecesof length  from  rod and throw away a piece of length .From  rod, we will cut  pieces of length  andthrow a piece of length . So in total we have  pieces of length  andwe have made  cuts also. So total profit is
Sample Input#01
100
10
3
26
103
59
Sample Output#01
1230

. more info on 1point3acres.com
补充内容 (2016-10-4 07:42):
BruteForce 做,把maxRange内所有cutLength都遍历一遍,求高级解法!
更多图片 小图 大图
组图打开中,请稍候......
oily 发表于 2016-10-4 23:28:23 | 显示全部楼层
话说这题brute force做好像也不会超时吧,他限定范围那么小。。。
回复 支持 反对

使用道具 举报

sccnju 发表于 2016-10-5 01:13:33 | 显示全部楼层
我也只想到brutal force,但感觉每次要遍历的cut-length很多啊。。
回复 支持 反对

使用道具 举报

 楼主| bcc 发表于 2016-10-20 00:30:10 | 显示全部楼层
brute force 超时了,而且lz挂了。。。。
回复 支持 反对

使用道具 举报

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2016-12-7 01:04

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表