Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: The missionaries and cannibals
Description The missionaries and cannibals problem is usually stated as follows: Three missionaries and three cannibals are on one side of a river, along with a boat that can hold one or two people. Find a way to get everyone to the other side, without ever leaving a group of missionaries in one place outnumbered by the cannibals in that place. Now the problem has been extended to be more complicated. There are Input The first line of the input is an integer T which indicates the number of test cases. Each test case is specified on a separate line and is made of two positive number Output For each test case, output the result on a single line. If the problem can't be solved, print -1 as the result. Sample Input 2 3 2 20 3 Sample Output 11 -1 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator