07年5月PD想催绿, 求解答# EB23 - 劳工卡
g*l
1 楼
公司名字不方便说, 签了 NDA. 开始以为很容易, 就是简单算数计算. 后来面世官提示即使 D*F>C, 结
果可能是大于零的. 我然后望 DP 方向想, 但当场没想出什么好方法, 有大牛给指点一下, 谢先!
碰到这样的题,面世官也不给很多提示, 大家都这么应付的? 干瞪眼想还是说不会,让他换一道? 唉, 大概
还是自己不够 smart, 牛公司去不了.
A pile of nuts is in an oasis, across a desert from a town. The pile
contains 'N' kg of nuts, and the town is 'D' kilometers away from the
pile.
The goal of this problem is to write a program that will compute 'X',
the maximum amount of nuts that can be transported to the town.
The nuts are transported by a horse drawn cart that is initially next
to the pile of nuts. The cart can carry at most 'C' kilograms of nuts
at any one time. The horse uses the nuts that it is carrying as fuel.
It consumes 'F' kilograms of nuts per kilometer traveled regardless
of how much weight it is carrying in the cart. The horse can load and
unload the cart without using up any nuts.
Your program should have a function that takes as input 4 real numbers
D,N,F,C and returns one real number: 'X'
果可能是大于零的. 我然后望 DP 方向想, 但当场没想出什么好方法, 有大牛给指点一下, 谢先!
碰到这样的题,面世官也不给很多提示, 大家都这么应付的? 干瞪眼想还是说不会,让他换一道? 唉, 大概
还是自己不够 smart, 牛公司去不了.
A pile of nuts is in an oasis, across a desert from a town. The pile
contains 'N' kg of nuts, and the town is 'D' kilometers away from the
pile.
The goal of this problem is to write a program that will compute 'X',
the maximum amount of nuts that can be transported to the town.
The nuts are transported by a horse drawn cart that is initially next
to the pile of nuts. The cart can carry at most 'C' kilograms of nuts
at any one time. The horse uses the nuts that it is carrying as fuel.
It consumes 'F' kilograms of nuts per kilometer traveled regardless
of how much weight it is carrying in the cart. The horse can load and
unload the cart without using up any nuts.
Your program should have a function that takes as input 4 real numbers
D,N,F,C and returns one real number: 'X'