Problem:
There are four people need to cross the bridge, the sky is relatively dark, the bridge must use a flashlight. But there is only one flashlight, each time a maximum of two people cross the bridge, so someone must bring the flashlight back and forth. The four of them need 1,2,5,10 minutes to cross the bridge, and two people will cross the bridge at a slower pace. Excuse me, how to cross the bridge within 17 minutes.
Reply:
Specifically I do not know what the algorithm is contained in the inside ... Just thought for a moment. The key to solving this problem is that people have to go back and forth at least. And, try to get 5 minutes and 10 minutes to walk together, saving more time.
- It takes 2 minutes to cross the bridge first.
- 2 Go back, spend 2 minutes, total 4 minutes
- 5,10 Bridge, take 10 minutes, total 14 minutes
- 1 Go back, spend 1 minutes, total 15 minutes
- It takes 2 minutes and a total of 17 minutes to cross the bridge.
Four people 17 minutes cross the bridge problem