文学城论坛
+A-

回复:回复:求救!咋样,可以成攻救人?

piffle 2010-09-29 12:31:33 ( reads)

Assume:

P1 is the person that needs 1 minute to cross
P2 is the person that needs 2 minutes to cross
P5 is the person that needs 5 minutes to cross
P10 is the person that needs 10 minutes to cross

A is one side of the bridge and B is the other side.

Beginning state: A(P1, P2, P5, P10) - B()

Step 1: A(P5, P10) - B(P1, P2) ==> 2 min : this means P1 and P2 cross the bridge together, use 2 minutes

Step 2: A(P1, P5, P10) - B(P2) ==> 1 min

Step 3: A(P1) - B(P2, P5, P10) ==> 10 min

Step 4: A(P1, P2) - B(P5, P10) ==> 2 min

Step 5: A() - B(P1, P2, P5, P10) == > 2 min

Total : 17 min

跟帖(1)

newers

2010-10-03 07:32:54

Another solution: switching P1 and P2 also works