No.1770 Don't Say N Game (6)
タグ : / 解いたユーザー数 25
作問者 :
trineutron
/ テスター :
ngtkana
Problem Statement
You and Grant have played many times a game that extends the so-called "Don't Say $21$ Game" (also known in some places as the stick-taking game) using positive integers $N, K$. The rules are as follows.
1. First, the player moving first is given $0$.
2. The player adds one of the integers $1〜K$ to the given number, declares the result, and passes it to the opponent, trying not to declare a number that is $N$ or greater (declaring such a number means losing).
3. The players take turns repeating step 2. until the game is decided.
Since you have learned how to win this game, Grant has become unable to win it.
So Grant decided to challenge you with the following rule added.
4. If the integer a player adds is the same as the one the opponent added immediately before, that player loses at that moment. For example, if you declared $10$ and Grant declared $12$, then you lose if you declare $14$.
You move first and start the game.
Assuming that both players play so as not to lose, given natural numbers $N,K$,
if you can win, output all the numbers you can declare first in order to win, in ascending order, separated by newlines. If you cannot win, output $0$.
Input
$N\ K$
$N, K$ are integers
$1 \le K < N \le 2 \times 10^5$
Output
If you can win, output all the numbers you can declare first in order to win, in ascending order, separated by newlines. If you cannot win, output $0$ followed by a newline.
Sample
Sample 1
Input
21 3
Output
0
Whatever strategy you take, you cannot beat Grant.
Sample 2
Input
13 5
Output
5
You can win only when you declare $5$ on your first move.
Sample 3
Input
40 6
Output
2 4
If there are multiple winning first moves, output them in ascending order.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。