饥饿的卡车司机
Hungry Truck Driver
题目详情
一名卡车司机的任务是在 和 城镇之间运输 苹果,这两个城镇相距 英里。然而,如果卡车司机在卡车里有苹果的情况下开车,他将以每英里 苹果的速度吃掉它们。该卡车每次最多可容纳 苹果。司机可以在 和 之间的任何点存放苹果。
他怎样才能从 镇到 镇获得尽可能多的苹果?
A truck driver has been tasked with transporting apples between towns and , which are miles apart. However, if the truck driver is driving while there are apples in his truck, he will eat them at a rate of apple per mile. The truck has a maximum capacity of apples at any one time. The driver may deposit apples at any point between and .
How can he get the maximum possible number of apples from town to town ?
解析
我们有:
- 苹果总数:3000
- 卡车容量:1000
- 距离:1000 英里
- 消耗量:每次装载每英里 1 个苹果
将旅程分为几个阶段,每个阶段我们在两点之间运输苹果,逐渐减少苹果总量。在每个阶段,我们都会优化移动苹果的距离,以最大限度地减少消耗。
搬运 3000 个苹果,卡车容量 1000 每英里吃掉的苹果: 距离 2000 个苹果还剩: 英里
移动 2000 个苹果,k = 2 趟 每英里吃掉的苹果: 距剩余 1000 个苹果的距离: 英里
移动剩余的 1000 个苹果,k = 1 趟 每英里吃掉的苹果: 到 B 镇的距离: 英里 吃掉的苹果:466.67 → 交付的苹果:
Original Explanation
We have:
- Total apples: 3000
- Truck capacity: 1000
- Distance: 1000 miles
- Consumption: 1 apple per mile per load
Divide the journey into stages, where at each stage we transport apples between two points, reducing total apples gradually. At each stage, the distance we move apples is optimized to minimize consumption.
Move 3000 apples, truck capacity 1000
Apples eaten per mile:
Distance until 2000 apples remain: miles
Move 2000 apples, k = 2 trips
Apples eaten per mile:
Distance until 1000 apples remain: miles
Move remaining 1000 apples, k = 1 trip
Apples eaten per mile:
Distance to town B: miles
Apples eaten: 466.67 → Apples delivered: