#P7656. Unique Move Subtraction Game
Unique Move Subtraction Game
Unique Move Subtraction Game
This is a two-player game played with two integer variables n and m. Players A and B take turns (with A moving first) subtracting a positive integer k from n. On each turn, the chosen number k must satisfy \(k \leq \min\{m, n\}\) and may not have been used in any previous move by either player. The game ends when the current player has no available moves, and the player who made the last valid move is declared the winner.
Given the values of n and m, determine which player has a winning strategy if both play optimally. Note that if n is greater than the sum of all numbers from 1 to m (i.e. \(T = \frac{m(m+1)}{2}\)), then all moves can be played; in that case, the outcome is determined by the parity of m (Player A wins if m is odd, and Player B wins if m is even).
inputFormat
The input consists of two space-separated integers n and m on a single line.
\(1 \leq n, m \leq\) (limits such that a complete search using dynamic programming with bitmask is feasible).
outputFormat
Output a single character: A
if Player A (the first player) has a winning strategy, otherwise output B
.
sample
2 2
A