A - Sum and Product
Editorial
/
Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 300 点
問題文
整数 S,P が与えられます。 N+M=S,N \times M =P を満たすような正の整数の組 (N,M) はありますか?
制約
- 与えられる入力は全て整数
- 1 \leq S,P \leq 10^{12}
入力
入力は以下の形式で標準入力から与えられる。
S P
出力
N+M=S,N \times M =P を満たすような正の整数の組 (N,M) があるなら Yes
、そうでないなら No
を出力せよ。
入力例 1
3 2
出力例 1
Yes
- 例えば N=1,M=2 のとき、N+M=3,N \times M =2 となります。
入力例 2
1000000000000 1
出力例 2
No
- そのような (N,M) は存在しません。
Score : 300 points
Problem Statement
Given are integers S and P. Is there a pair of positive integers (N,M) such that N + M = S and N \times M = P?
Constraints
- All values in input are integers.
- 1 \leq S,P \leq 10^{12}
Input
Input is given from Standard Input in the following format:
S P
Output
If there is a pair of positive integers (N,M) such that N + M = S and N \times M = P, print Yes
; otherwise, print No
.
Sample Input 1
3 2
Sample Output 1
Yes
- For example, we have N+M=3 and N \times M =2 for N=1,M=2.
Sample Input 2
1000000000000 1
Sample Output 2
No
- There is no such pair (N,M).