No.1198 Candy Distribution - 1
タグ : / 解いたユーザー数 281
作問者 :
PCTprobability
/ テスター :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。