老外面试时候考的逻辑题——网上找了个类似的
题目1:Four people come to a river in the night. There is a narrow bridge, but it can only hold two people at a time. They have one torch and, because it's night, the torch has to be used when crossing the bridge. Person A can cross the bridge in one minute, B in two minutes, C in five minutes, and D in eight minutes. When two people cross the bridge together, they must move at the slower person's pace. The question is, can they all get across the bridge in 15 minutes or less?
四个人晚上过一个窄桥,桥每次只能通过两个人;过桥的时候必须用到火炬,但四个人只有一个火炬;其中A过桥需要1分钟,B需要2分钟,C需要5分钟,D需要8分钟,而且两个人一起过桥的时候必须以比较慢的人的步伐为准,问四个人如何在15分钟或更少的时间全部通过?
解答:
比较常见的逻辑,花费17分钟
所花时间Elapsed Time | 开始边Starting Side | 动作Action | 结束边Ending Side |
---|---|---|---|
0 minutes | A B C D | ||
2 minutes | C D | A和B 过桥,耗时2分钟 | A B |
3 minutes | A C D | A返回,耗时1分钟 | B |
8 minutes | D | A和C 过桥,耗时5分钟 | A B C |
9 minutes | A D | A返回,耗时1分钟 | B C |
17 minutes | A和C 过桥,耗时8分钟 | A B C D |
比较妙的逻辑,花费15分钟
所花时间Elapsed Time | 开始边Starting Side | 动作Action | 结束边Ending Side |
---|---|---|---|
0 minutes | A B C D | ||
2 minutes | C D | A和B 过桥,耗时2分钟 | A B |
3 minutes | A C D | A返回,耗时1分钟 | B |
11 minutes | A | D和C 过桥,耗时8分钟 | B C D |
13 minutes | A B | B返回,耗时2分钟 | C D |
15 minutes | A和B 过桥,耗时2分钟 | A B C D |
题目2:盒子里放了黑白两种颜色各十个球,蒙上双眼取球,要求每次取一个,要取多少次才能确保取出来的球有一对颜色一样的球?
两次?
转载于:https://www.cnblogs.com/JoannaQ/archive/2013/03/19/2968503.html