No.2781 A%B Problem
Problem Statement
You are given $2$ integers $A, B$ as input, where $B \neq 0$.
Find the remainder when $A$ is divided by $B$.
In this problem, "the remainder when $A$ is divided by $B$" refers to the unique non-negative integer $r$ less than $|B|$ such that there exists an integer $q$ satisfying $A = Bq+r$.
Input
The input is given from standard input on $1$ line in the following format:
$A$ $B$
That is, $A, B$ are given separated by a half-width space.
Constraints
The input satisfies the following constraints:
- $A$ is an integer satisfying $-10^2 \leq A \leq 10^2$.
- $B$ is an integer satisfying $-10^2 \leq B \leq 10^2$ and $B \neq 0$.
Output
Output the remainder when $A$ is divided by $B$ on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
1 1
Output
0
Since $1 = 1 \times 1 + 0$ and $0 < |1|$, the remainder when $1$ is divided by $1$ is $0$.
Sample 2
Input
1 -2
Note that $B$ may be negative, as in this case.
Output
1
Since $1 = (-2) \times 0 + 1$ and $1 < |{-2}|$, the remainder when $1$ is divided by $-2$ is $1$.
Sample 3
Input
-1 2
Note that $A$ may be negative, as in this case.
Output
1
Since $-1 = 2 \times (-1) + 1$ and $1 < |2|$, the remainder when $-1$ is divided by $2$ is $1$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。