#P9486. Bash Game with Optional Move

    ID: 22635 Type: Default 1000ms 256MiB

Bash Game with Optional Move

Bash Game with Optional Move

In this problem, two players, A and B, play a game with a pile of \( n \) items. Initially, player A takes the first move. In each move, a player may remove between 1 and \( m \) items from the pile. The player who takes the last item wins the game.

The game has an additional twist: a player is allowed to pass (i.e. choose not to remove any items) when it is their turn. However, if a player passes, then in the next \( k \) moves both players are forced to remove at least 1 item (i.e. the pass option is not available during these forced moves). Once these \( k \) forced moves are over, the pass option becomes available again.

You are given \( t \) games. For each game, you are provided with the parameters \( n \), \( m \) and \( k \). Your task is to determine whether player A (the first player) has a winning strategy assuming both players play optimally.

The rules can be summarized as follows:

  • There is a pile of \( n \) items.
  • Players A and B take turns. A starts first.
  • When not in a forced move sequence (i.e. when the "pass restriction" is not active), a player may either remove between 1 and \( m \) items, or choose to pass.
  • If a player passes, then for the next \( k \) moves the pass option is disabled (both players must remove at least 1 item).
  • The player who removes the last item wins the game.

Note: In moves where the pass option is disabled, the only allowed moves are to remove between 1 and \( m \) items.

inputFormat

The first line contains an integer \( t \) (the number of games).

Each of the next \( t \) lines contains three integers \( n \), \( m \), and \( k \) separated by spaces, representing one game.

\( 1 \leq n, m \leq 10^3 \) and \( 0 \leq k \leq 10^3 \) (note that \( k=0 \) means the pass move is never forced and is always available).

outputFormat

For each game, output a single line containing Yes if player A has a winning strategy, or No otherwise.

sample

1
1 1 1
Yes

</p>