SYNC13C - WHAT A CO-ACCIDENT
Ramesh and Suresh get a box full of five stars on lottery each. Since both the boxes need not have the same number of chocolates, they decide to play a game. The winner gets to have both the boxes of chocolates. They play alternatively and Suresh starts the game.
Given the number of chocolates in both the boxes, let them be c1 and c2, the player takes either c1 or c2 number of chocolates and divide the remaining box of chocolates to two boxes (these two boxes need not have the same number of chocolates). The player who cannot make such a move loses.
Given the initial number of chocolates (c1 and c2) find the winner.Assume both the players play optimally.
First line of input contains a number T(1<=T<=1000), the number of test cases. Then follows T lines each containing two space separated integers c1 and c2
For each test case print "Ramesh" or "Suresh" depending on who is the winner.
4 5 Output:
just think by making cases...!!!
My easiest on spoj.....
Comments absolutely spoil the fun
Hit and Trial got AC on 4th Trial..hehe
Consider the test case 2,2 in which Suresh wins.
just if else ...base cases lead to logic....easy !! AC in 1 go :-)
straight away go to the base cases in these type of questions.Don't get disheartened by seeing the comments in case if you didn't find it that easy :)
2 lines of code in python.. Just have to hit the logic.. :D AC in one go..
@mayank since the chocolates can be divided in unequal number of chocolates and player will choose the optimal path possible so in case 2: 4,5