The Rope Bridge

来源:互联网 发布:如何实现云计算 编辑:程序博客网 时间:2024/05/23 00:20
Four people need to cross a rickety rope bridge to get back to their camp at night.
Unfortunately, they only have one flashlight and it only has enough light left for seventeen
minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough
to support two people at any given time. Each of the campers walks at a different speed. One
can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the
slowpoke takes 10 minutes to cross.

Tell these campers how they can make it across in 17 minutes.

solution:

第一趟,先让1,2先走;

第二趟,然后1返回;

第三趟,5和10走;

第四趟,2返回;

第五趟,1,2走。

thinking:

每次只能两个人过桥,因此必须有一个人返回,为了节省时间返回的人必须用时最短。但是,如果把5和10 分隔开,会额外添加5分钟,因此5和10搭配,让2返回。

PS.

想一想怎么用C或JAVA实现

0 0
原创粉丝点击