返回题库

运苹果问题

The truck can hold at most only 1,000 apples

专题
Brainteaser / 脑筋急转弯
难度
L6

题目详情

两座城市 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 英里,需要的满载前进趟数为:

  • 苹果数 >2000>2000:需要 3 趟(最多每趟 1000);每英里损耗 3 个;
  • 苹果数在 (1000,2000](1000,2000]:需要 2 趟;每英里损耗 2 个;
  • 苹果数在 (0,1000](0,1000]:需要 1 趟;每英里损耗 1 个。

从 A 出发:

  1. 用 3 趟模式走 334334 英里,损耗 3×334=10023\times 334=1002 个,剩 30001002=19983000-1002=1998 个;

  2. 用 2 趟模式再走 499499 英里,损耗 2×499=9982\times 499=998 个,剩 1998998=10001998-998=1000 个;此时已走到 334+499=833334+499=833 英里处;

  3. 余下 1000833=1671000-833=167 英里,单趟直达损耗 167 个。

最终到 B 城为 1000167=8331000-167=\boxed{833} 个苹果。


英文解析

Key: The driver eats 1 apple for every mile traveled while carrying apples; no loss occurs when returning empty.

Therefore, on a given segment, the number of full-load trips required to move all apples 1 mile forward is:

  • If the number of apples >2000>2000: 3 trips are needed (at most 1000 per trip); 3 apples are lost per mile.
  • If the number of apples is in (1000,2000](1000, 2000]: 2 trips are needed; 2 apples are lost per mile.
  • If the number of apples is in (0,1000](0, 1000]: 1 trip is needed; 1 apple is lost per mile.

Starting from A:

  1. Travel 334 miles using the 3-trip mode, losing 3×334=10023 \times 334 = 1002 apples, leaving 30001002=19983000 - 1002 = 1998 apples;
  2. Travel another 499 miles using the 2-trip mode, losing 2×499=9982 \times 499 = 998 apples, leaving 1998998=10001998 - 998 = 1000 apples; at this point, the distance covered is 334+499=833334 + 499 = 833 miles;
  3. The remaining distance is 1000833=1671000 - 833 = 167 miles, with a single-trip loss of 167 apples.

The final number of apples arriving at city B is 1000167=8331000 - 167 = \boxed{833}.