Codeforces Round 1066 (Div. 1 + Div. 2)
I
Hyper Smawk Bros
Codeforces
3500
原题
← H→
翻译中…

You and Bob are playing Hyper Smawk Bros against each other, facing a single boss with health $n$.

翻译中…

You and Bob act alternately, and you start. On your turn, you may use an attack that deals an integer amount of damage $x$ in $[1, m]$, replacing $n$ with $n - x$. However, one cannot use the same $x$ that his opponent just used on the previous turn (on the very first move of the game, any $x$ in $[1, m]$ is allowed).

翻译中…

The winner is the first player to reduce the boss's health to $n \leq 0$. Determine whether you can force a win if Bob plays optimally.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The only line of each test case contains two integers $n$, $m$ ($1 \le n \le 10^6$, $2 \leq m \leq 10^6$) — the starting health $n$ and the maximum damage per attack $m$.

翻译中…

Note that there are no constraints on the sum of $n$ over all test cases, and there are no constraints on the sum of $m$ over all test cases.

翻译中…

Output

翻译中…

For each test case, output $\texttt{YES}$ if you can force a win against Bob, and $\texttt{NO}$ otherwise.

翻译中…

The judge is case-insensitive (for example, $\texttt{YES}$, $\texttt{Yes}$, $\texttt{yes}$, $\texttt{yEs}$ will all be recognized as positive answers).

翻译中…

Note

翻译中…

In the first test case, you can win immediately by dealing damage $8$, so that $n$ becomes $6-8 = -2 \leq 0$.

翻译中…

In the second test case,

翻译中…
  • you choose to deal damage $10$;
  • Bob can choose to deal any damage in $[1, 10]$ different from $10$;
  • then you can choose to deal damage $10$ and win.
翻译中…

In the third test case,

翻译中…
  • either you start by dealing damage $1$, then Bob must deal damage $2$, then you must deal damage $1$, etc.;
  • or you start by dealing damage $2$, then Bob must deal damage $1$, then you must deal damage $2$, etc.
翻译中…

In both cases, you lose.

翻译中…

样例

Input #1
8
6 9
20 10
69 2
42 9
42 10
44 9
44 10
400000 400000
Output #1
YES
YES
NO
NO
YES
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
2157I
时间限制
4 s
内存限制
1024 MB
标签
动态规划
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。