P5497 [LnOI2019SP] Turtle-Speed Single-Term Transformation (SMT).

Background

Problem provider: Asada Shino. As everyone knows, this is a check-in problem.

Description

The following definition is given: if, in a positive integer sequence $a$, there exists a sum of several consecutive positive integers that is a multiple of $m$, then the positive integer sequence $a$ is called an “$m$ sequence”. Given $n$ and $m$, you need to determine whether every positive integer sequence $a$ of length $n$ is an “$m$ sequence”.

Input Format

Two numbers, $n$ and $m$.

Output Format

If it holds, output `YES`; otherwise output `NO`.

Explanation/Hint

Sample explanation: there exists a counterexample $[1, 2]$. Subtask 1 (50 pts): $1 \le n, m \le 5$. Subtask 2 (50 pts): $1 \le n, m \le {10}^{18}$. Translated by ChatGPT 5