#P4236. Winning Strategy for the Exponential Card Game
Winning Strategy for the Exponential Card Game
Winning Strategy for the Exponential Card Game
In this game, lsq and wzt play with a deck of n cards (without jokers). In each move, the current player draws a number of cards equal to \(a^k\), where \(a\) is a given positive integer and \(k\) is any nonnegative integer chosen by the player. Note that when \(a=1\), the only available move is to take 1 card since \(1^k=1\) for any \(k\). The players take turns starting with lsq. The player who draws the last card wins. Both players always use a winning move if one exists.
There will be q rounds. In each round the values of \(a\) and \(n\) can be different. Your task is to determine, for each round, whether lsq (the first player) can force a win under optimal play. You do not need to output the winning strategy, only whether lsq can win.
Note: All exponentiation must be represented in \(\LaTeX\) format, e.g. \(a^k\).
inputFormat
The first line contains an integer \(q\) (the number of rounds). Each of the next \(q\) lines contains two integers \(a\) and \(n\) separated by a space.
\(a\) is the base for the exponentiation in the move (with \(a \ge 1\)). \(n\) is the total number of cards available in that round.
outputFormat
For each round, output a single line containing Yes
if lsq can force a win, otherwise output No
.
sample
1
1 1
Yes
</p>