問題一覧 > 教育的問題

No.2192 Last 14 Digits of a Square Number

レベル : / AI推定難易度 : 1900 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 6
作問者 : 👑 p-adic / テスター : 👑 qand
お気に入りにしたユーザー ProblemId : 8719 / 自分の提出
問題文最終更新日: 2023-03-04 10:13:02
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 373 (順位表) の他の問題:

Problem Statement

You are given as input a non-negative integer $B$ that is at least $2$, and a non-negative integer $N$ less than $B$.

 

Determine whether there exists a square number whose remainder when divided by $B$ is equal to $N$.

Input

The input is given from standard input in the following format:

$B$
$N$

Constraints

The input satisfies the following constraints:

  • $B$ is a non-negative integer between $2$ and $10^{14}$, inclusive
  • $N$ is a non-negative integer less than $B$

Output

Print YES if there exists a square number whose remainder when divided by $B$ is equal to $N$, and NO otherwise.

Print a newline at the end.

Sample

Sample 1
Input
100000000000000
0
Output
YES

Examples of square numbers whose remainder when divided by $10^{14}$ is equal to $0$ include $0$ and

$\displaystyle 100000000000000 = 10000000^2 $

.

Sample 2
Input
100000000000000
1
Output
YES

Examples of square numbers whose remainder when divided by $10^{14}$ is equal to $1$ include $1$ and

$\displaystyle 1000000000000200000000000001 = 100000000000001^2 $

.

Sample 3
Input
100000000000000
2
Output
NO

There is no square number whose remainder when divided by $10^{14}$ is equal to $2$.

Sample 4
Input
100000000000000
96290312864656
Output
YES

An example of a square number whose remainder when divided by $10^{14}$ is equal to $96290312864656$ is

$\displaystyle 10596290312864656 = 102938284^2 $

.

Sample 5
Input
100000000000000
95993098537891
Output
NO

There is no square number whose remainder when divided by $10^{14}$ is equal to $95993098537891$.

Sample 6
Input
99999999999973
99876000273817
Output
YES

An example of a square number whose remainder when divided by $99999999999973$ is equal to $99876000273817$ is

$\displaystyle 999999876000003844 = 999999938^2 $

.

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