卡车最多装 1000 个苹果:运 3000 个到 100
The truck can hold at most only 1,000 apples
题目详情
两座城市 A 与 B 相距 1000 英里。A 城有 3000 个苹果,想尽可能多地运到 B 城。
唯一运输方式是一辆卡车,但有两个限制:
- 卡车最多只能装 1000 个苹果;
- 只要卡车里有苹果,司机每开 1 英里就会偷吃 1 个苹果。
你可以中途停下把苹果卸在路边,再回头取下一批。
问:最多能把多少苹果从 A 运到 B?
There are two cities, A and B, 1,000 miles apart. You have 3,000 apples at City A, and you want to deliver as many as possible of them to City B. The only delivery
method available is a truck. There are, however, two problems. The truck can hold at most only 1,000 apples, and if there are any apples at all in the truck, the hungry dishonest driver will steal and eat one apple for every mile he drives. What is the maximum number of apples you can deliver from City A to City B? Note that you are welcome to stop part way, dump off some apples, and then come back and pick them up later.
解析
关键:司机每“载着苹果前进 1 英里”都会吃 1 个苹果;空车返回不损耗。
因此在某段路上,如果要把全部苹果前移 1 英里,需要的满载前进趟数为:
- 苹果数 :需要 3 趟(最多每趟 1000);每英里损耗 3 个;
- 苹果数在 :需要 2 趟;每英里损耗 2 个;
- 苹果数在 :需要 1 趟;每英里损耗 1 个。
从 A 出发:
-
用 3 趟模式走 英里,损耗 个,剩 个;
-
用 2 趟模式再走 英里,损耗 个,剩 个;此时已走到 英里处;
-
余下 英里,单趟直达损耗 167 个。
最终到 B 城为 个苹果。