No.485 Studying Equations
タグ : / 解いたユーザー数 754
作問者 :
tatuyan_edson
Problem Statement
Kuro-kun is starting to get hooked on solving equations.
Today he will solve many equations of the form $Ax = B$.
Kuro-kun has not learned decimals or fractions at school, so he cannot solve a problem if the solution $x$ is not an integer.
Your job as his private tutor is to prepare the answers before Kuro-kun solves the problems.
Output the solution $x$ if the problem is one Kuro-kun can solve, or "NO" if it is one he cannot solve.
Input
$A$ $B$
$-100\le A \le -1$ or $1\le A \le 100$
$-100\le B \le -1$ or $1\le B \le 100$
$A,\ B$ are integers.
Output
If the solution $x$ of $Ax = B$ is an integer, output the solution $x$; otherwise, output "NO".
Print a newline at the end.
Sample
Sample 1
Input
3 12
Output
4
The $x$ satisfying $3 \times x = 12$ is $4$.
Since $4$ is an integer, this is a problem Kuro-kun can solve.
Sample 2
Input
-2 6
Output
-3
Kuro-kun is used to handling negative numbers.
Sample 3
Input
7 10
Output
NO
This is a problem Kuro-kun cannot solve.
Sample 4
Input
1 -1
Output
-1
There are problems where $A$ or $B$ is $1$ or $-1$, but there are no problems where either is $0$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。