Number Game RevisitedProblem code: NUMGAME2 |
All submissions for this problem are available.
Alice and Bob play the following game.They choose a number N to play with.The runs are as follows :
1.Bob plays first and the two players alternate.
2.In his/her turn ,a player can subtract from N any prime number(including 1) less than N.The number thus obtained is the new N.
3.The person who cannot make a move in his/her turn loses the game.
Assuming both play optimally,who wins the game ?
Input format:
The first line contains the number of test cases T.Each of the next lines contains an integer N.
Output format:
Output T lines one for each test case,containing "ALICE" if Alice wins the game ,or "BOB" if Bob wins the game.
Example
Sample Input: 2 1 2
Sample Output: ALICE BOB
Constraints: 1 <= T <= 1000000 1 <= N <= 1000000000
Note : For the first test case, Bob cannot make any move and hence Alice wins the game. For the second test case, Bob subtracts 1 from N. Now, Alice cannot make a move and loses the game.
| Author: | nssprogrammer |
| Tester: | rajivka |
| Editorial | http://discuss.codechef.com/problems/NUMGAME2 |
| Date Added: | 23-11-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
|
If you are still having problems, see a sample solution here. |

Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
how is the if(n%4==1)
i got IT how it works!!!
Where can I get more Test
Please explain me this....
Any one can please explain me
hey can anyone tell me dat
hey...cn u plz tell tht how
@anick_gemini Both players
@adm why 1 cant be choosen as
I am not getting the logic of
If you try to solve the
How to get to the reasoning
Please dont post answers...