問題一覧 > 通常問題

No.1198 Candy Distribution - 1

レベル : / AI推定難易度 : 625 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 281
作問者 : PCTprobability / テスター : NatsubiSogan
お気に入りにしたユーザー ProblemId : 4763 / 自分の提出
問題文最終更新日: 2020-08-28 23:15:16
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 263 (順位表) の他の問題:

Problem Statement

PCT-san, who is kind to children, has decided to hand out candies to the children gathered at a party.
PCT-san initially had $A^2$ candies, and after giving $B$ candies each to $B$ children, $N$ candies remained on hand.
Determine whether such a pair of positive integers $A,\ B\ (A>B)$ exists.

More formally, you are given a positive integer $N$. Output $1$ if there exists a pair of positive integers $A,\ B\ (A>B)$ such that $A^2-B^2=N$, and $-1$ if no such pair exists.

Pay attention to the constraints.

Input

$N$

  • All inputs are integers.
  • $1 \le N \le 10^{25}$

Output

Output $1$ if there exists a pair of positive integers $A,\ B$ satisfying the conditions in the problem statement, and $-1$ otherwise. Print a newline at the end.

Sample

Sample 1
Input
2
Output
-1

In this case, no $A,\ B$ satisfying the conditions exist.

Sample 2
Input
8
Output
1

For example, $3^2-1^2=8$ satisfies the conditions.

Sample 3
Input
456454
Output
-1

Sample 4
Input
123456789
Output
1

For example, $18917^2-15310^2=123456789$ satisfies the conditions.

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