Alphabets and Utthaan
All submissions for this problem are available.
This year at Utthaan, a lot of events are being organized. An event will be hosted for the 'Alphabets' too. All the Alphabets (a-z) are to gather at a place and will have play marbles as per the following rules.
- Only two 'Alphabets' will play with marbles at a time and with n number of marbles.
- The game will be played first between the two 'Alphabets' with least ASCII values.
- Between those alphabets, the one with lower ASCII value will pick the marble(s) first.
- They are given n number of marbles and one can choose either 1, x or y number of marbles to pick at a time.
- The winner is the one who picks the last marble.
- The winner persists in the game and and the looser is eliminated.
For Example: a and b first plays the game. The winner of this game, plays with c and so on, up to z.
After hearing this, Chef immediately came up with a conclusion that there will be some cases when the alphabet which starts the game could win, no matter how the other alphabet plays. And in other cases, the second alphabet being careful, can win, no matter how the first alphabet plays.
You are given the number of marbles in each game. Print just one alphabet in each case, the winner of the whole game.
- First line contains three space separated integers x y and T, T being the number of test cases.
- Next line contains 25 space separated integers, for the no. of marbls for each game
Output the alphabet which will win, for each case in a new line (small case).
- 1 ≤ T ≤ 100
- 1 ≤ x < y ≤ 30
- 1 ≤ n ≤ 105
Input: 2 3 1 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Output: y
In the game between a and b, a can choose either 1, 2 or 3 marbles to pick at a time. 'A' will want to pick all 3 marbles to win. Then the game is played between a and c with 2 marbles, and the game continues leaving y as the winner.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.