All submissions for this problem are available.
2 players A and B are playing a game taking turns alternatively.They are given an array of 'N' numbers : X,X.....X[N] ..
During each turn , the player selects an index 'i' <= (N/2) such that X[i] > 0 ,
subtracts 1 from X[i] and adds 1 to either X[2*i],X[3*i] or X[5*i] ( Obviously the index to which the player is adding should be less than or equal to N ) .
Player A starts the game and makes the first move.The player who can't make a move loses the game.
Both the players are playing optimally. Determine the winner of this game.
- The first line of the input contains an integer N
- Next line contains N integers X,X, ..... X[N]
- Output a single line containing the winner : "A" or "B".
- 1 ≤ N ≤ 100000
- 0 ≤ X,X.....X[N] ≤ 1000000000
0 0 1 0 0
0 1 0 0 0
Example case 1 : Player A can't make a move because X = 0 and X = 0.
Example case 2 : Player A has only 1 possible move ( X = X - 1 , X = X+1). After that the array becomes : 0 0 0 1 0
Now B can't make a move and hence B loses. Note that when A selected index i = 2 , both i*3,i*5 were greater than N and hence only 1 move was possible.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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