問題一覧 > 教育的問題

No.3233 Permutation Check

レベル : / AI推定難易度 : 243 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 95
作問者 : 👑 p-adic / テスター : YY-otter
お気に入りにしたユーザー ProblemId : 10680 / 自分の提出
問題文最終更新日: 2024-06-02 16:21:04
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
yukicoder contest 478 オムニバス (順位表) の他の問題:

Note

The execution time limit for this problem is 1000[ms].

Problem Statement

You are given $2$ positive integers $N, M$ as input.

 

Determine whether the integer sequence $A$ of length $N$, uniquely characterized by the following condition, is a permutation.

  • For any positive integer $i$ not exceeding $N$, the $i$-th component of $A$ is the remainder when $i^M$ is divided by $N$.

Here, $A$ being a permutation means that the components of $A$ are pairwise distinct.

Input

The input is given from standard input in $1$ line in the following format:

  • On line $1$, $N, M$ are given, separated by a half-width space.
$N$ $M$

Constraints

The input satisfies the following constraints:

  • $N$ is an integer satisfying $1 \leq N \leq 10^5$.
  • $M$ is an integer satisfying $1 \leq M \leq 10^2$.

Output

Print Yes if $A$ is a permutation, and No otherwise.

Print a newline at the end.

Sample

Sample 1
Input
1 1
Output
Yes

We have $A = (1^M \bmod N) = (1^1 \bmod 1) = (0)$, and $A$ has only $1$ component. In particular, $A$ is a permutation.

Sample 2
Input
2 1
Output
Yes

We have $A = (1^M \bmod N, 2^M \bmod N) = (1^1 \bmod 2, 2^1 \bmod 2) = (1,0)$, and the components of $A$ are pairwise distinct. That is, $A$ is a permutation.

Sample 3
Input
3 2
Output
No

We have $A = (1^M \bmod N, 2^M \bmod N, 3^M \bmod N) = (1^2 \bmod 3, 2^2 \bmod 3, 3^2 \bmod 3) = (1,1,0)$, and component number $1$ and component number $2$ of $A$ coincide, both being $1$. That is, $A$ is not a permutation.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。