Bob and Alice are playing a game with the following rules:
Initially, they have an integer sequence A1,A2,…,AN; in addition, Bob has a lucky number a and Alice has a lucky number b.
The players alternate turns. In each turn, the current player must remove a non-zero number of elements from the sequence; each removed element should be a multiple of the lucky number of this player.
If it is impossible to remove any elements, the current player loses the game.
It is clear that one player wins the game after a finite number of turns. Find the winner of the game if Bob plays first and both Bob and Alice play optimally.
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains three space-separated integers N, a and b.
The second line contains N space-separated integers A1,A2,…,AN.
For each test case, print a single line containing the string "ALICE" if the winner is Alice or "BOB" if the winner is Bob (without quotes).
1≤Ai≤109 for each valid i
Subtask #1 (18 points): a=b
Subtask #2 (82 points): original constraints
5 3 2
1 2 3 4 5
5 2 4
1 2 3 4 5
Example case 1: Bob removes 3 and the sequence becomes [1,2,4,5]. Then, Alice removes 2 and the sequence becomes [1,4,5]. Now, Bob is left with no moves, so Alice is the winner.
I cannot figure out what's wrong in my approach.
well this is your first post i see.
u must ask what problem u are having with the problem and leave a link to the problem instead of pasting the whole problem.
if u tell your approach maybe we could help you with where u are going wrong