回複:回複:求救!咋樣,可以成攻救人?

來源: 2010-09-29 12:31:33 [舊帖] [給我悄悄話] 本文已被閱讀:

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