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
|
||||||||
2015-07-14 18:30:43 goyal
@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 suresh will keep 5 with him and will divide 4 into two parts 1,3(chocolates can be unequal) and then ramesh have to pick 1 and divide 3 into two parts 1,2 and then suresh will pick 1 and will divide 2 into 1,1 that's it...:) |
||||||||
2015-05-17 13:19:43 Mayank
There's a confusion.. take the second case: 4,5 : suppose suresh begins with 5 then 4 can be divided into 2,2 and then ramesh picks 2 and then 2 can be divided into 1,1. Now suresh can't make the move. So how can he be the winner? or 4,5 : suresh picks up 4 and then 5 can be divided into 2,3 then ramesh picks up 2 then 3 : 1,2 then suresh picks up 1..so 2 : 1,1. This way suresh turns out to be the winner. |
||||||||
2015-01-31 12:47:01 Devashish Mathur
One of the easiest ones I solved on spoj... |
||||||||
2015-01-16 12:22:49 Rishabh
easy one ac in one go.......test case show the ans. |
||||||||
2015-01-16 12:22:15 anshal dwivedi
ac in one go ...very easy logic that used in SHAKTI |
||||||||
2014-12-22 14:50:20 Ojusvini Agarwal
(Y) LOGIC Last edit: 2014-12-22 14:57:05 |
||||||||
2014-12-10 21:50:54 PRAFFUL MEHROTRA
very easy!! |
||||||||
2014-10-06 19:00:17 Govind Lahoti
beautiful problem |
||||||||
2014-09-26 20:30:06 KAI
easy 1.silly mistake cost 1 wa :( |
||||||||
2014-09-21 01:39:00 Gaurav Bansal
code = too easy and logic = good |