Problem SOLUTION CODECHEF
Alice and Bob play a game.
They start with the integer � and take turns, with Alice going first.
On their turn, a player must select an odd prime factor � of �, and subtract it from � (so � changes to �−�).
The player who cannot make a move loses (that is, if either �=0 or � has no odd prime factors).
If Alice and Bob play optimally, who wins the game?
- The first line of input will contain a single integer �, denoting the number of test cases.
- The only line of each test case contains a single integer � — the value Alice and Bob start with.
For each test case, output on a new line the winner of the game — either
"Bob" (without quotes).
Each letter of the output may be printed in either uppercase or lowercase, i.e, the strings
boB will all be treated as equivalent.
2 2 5
Test case 1: 2 does not have any odd prime factor, so Alice cannot make a move and will lose immediately.
Test case 2: �=5. Alice can choose �=5, an odd prime factor of �, and subtract it.
This makes �=0, and Bob cannot move; making Alice the winner.
if n <= 1:
if n <= 3:
if n % 2 == 0 or n % 3 == 0:
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
i += 6
factors = 
if n % 2 == 0:
while n % 2 == 0:
n //= 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
n //= i
if n > 1:
odd_prime_factors = find_odd_prime_factors(N)
if len(odd_prime_factors) % 2 == 0:
T = int(input())
for _ in range(T):
N = int(input())
winner = game_winner(N)