Redirecting to
NADOS

Grundy Number

Two players Alice and Bob are playing a game. They have a pile with n coins in it.
They can pick only allowed numbers of coins at a time given in an array picks.
Alice goes first and they take alternate turns.
The player who picks the last coin is the winner. Can you find out the winner.
Input Format
The first line contains integer n(no. of coins in the pile).
Second line contains size of picks array say l
picks[0]
picks[1]
....
picks[l-1]
Output Format
Print the winner (ALICE or BOB).
Question Video
Constraints
1<= n <= 1000
Sample Input
8
3
5
1
4
Sample Output
BOB


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name