DiviDuelo
Time limit1sMemory limit1024 MB
Given N up to 10^12, decide whether the first player can force the gcd of their picked divisors to be greater than 1 under optimal play.
- Level
Medium6 of 10
- Topics
- Game theory, Number theory, Math
- Solved
- No attempts yet
Problem
The Intense Challenges Players Club (ICPC) is hosting a DiviDuelo tournament.
DiviDuelo is a new two-player, turn-based game. In DiviDuelo, a number is selected and the list of its divisors is written. For example, if is selected, the list 1, 2, 5, 10 is written. Players alternate turns, each picking one still unpicked divisor from the list, until all divisors have been picked.
The winner is determined by the greatest common divisor (GCD) of the numbers picked by the starting player. If the GCD is not equal to , the starting player wins. If the GCD is equal to , the other player wins.
The ICPC needs statistics about the games played in the tournament. Given , determine whether the starting player can win when both players play optimally.
Input
The input is a single line containing an integer (), the number selected for the game.
Output
Output a single line with the letter Y if the starting player can win, and the letter N otherwise, assuming both players play optimally.