Game of Stones
All submissions for this problem are available.
MJ and Abhinav are playing a game . The rules of the game are as follows:
• There are n piles of stones where ith pile has Ai stones.
• Each player can remove 1,2 or 4 stones from any pile in his chance.
• The players makes the moves alternately and Abhinav makes the first move.
• The player unable to make a move will lose.
Abhinav is very aggressive and he throws things here and there when loses. On the other hand MJ is very calm. If MJ wins Abhinav will break his new “ I Phone X ” in anger . Now, as both the players are very intelligent you can assume that both will play optimally. You have to determine wheather Abhinav’s “ I Phone X” is safe or not.
First line consists of a single integer N. The next line has N integers of Array A.
Print “YES” if “ I Phone X” is safe else print “NO” .
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ N ≤ 200000
- 1 ≤ Ai ≤ 200000
Input: 1 4 Output: YES
|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, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions