問題一覧 > 通常問題

No.1770 Don't Say N Game (6)

レベル : / AI推定難易度 : 1975 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 25
作問者 : trineutron / テスター : ngtkana
お気に入りにしたユーザー ProblemId : 3266 / 自分の提出
問題文最終更新日: 2022-04-26 02:08:41
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2021 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。