Submit | All submissions | Best solutions | Back to list |
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.
Input
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
(1 <= c1 <= c2 <= 10000).
Output
For each test case print "Ramesh
" or "Suresh
" depending on who is the winner.
Example
Input: 2 3 1 4 5 Output: Ramesh Suresh
Added by: | Pandian |
Date: | 2013-12-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
|
||||||||
2014-06-23 18:27:06 Kanav Vats
nice one indeed! |
||||||||
2014-06-16 11:31:54 sHaShAnK sHeKhAr
my 50th :) AC at 1 go! @Krit :thanks! |
||||||||
2014-06-12 16:52:02 karan
Easy Problem Just work out a few cases on paper ,you can easily come up with the solution :) |
||||||||
2014-03-31 11:03:49 nadavishe
Nice logic, love it |
||||||||
2014-02-01 19:52:40 Jumpy
little tricky |
||||||||
2014-01-23 19:54:19 Mitch Schwartz
Each box must be non-empty after every move. |
||||||||
2014-01-23 19:12:24 vank
if (x,1) is given can we pick x so that next turn will not be valid... |
||||||||
2014-01-23 06:11:13 Avinash
@lokesh k . Logic explanation for second case means, you are asking for 80% of solution. Last edit: 2014-01-23 12:14:49 |
||||||||
2014-01-22 22:34:43 Mitch Schwartz
@Olympus_Has_Fallen: The scenario you described is not optimal play. Moreover, explaining the second case could give too much away, so please don't do that or encourage others to do that here in the comments. By the way, guessing is not required for this problem; you can prove the result. |
||||||||
2014-01-21 13:35:48 Abhinav Gupta
(4,5)-> let suresh chooses 4 and let 5 is divided into (2,3). Now let ramesh chooses 3 and 2->(1,1).Now suresh cannot divide further.So,answr shd b ramesh.Plz help |