No.3773 mod A > mod B
Problem Statement
You are given positive integers $N, A, B$. Find the number of positive integers $n$ less than or equal to $N$ that satisfy the following condition.
- $(n\bmod A) > (n\bmod B)$
Here, $X\bmod Y$ denotes the remainder when $X$ is divided by $Y$.
Input
$N\ A\ B$
The input satisfies the following constraints.
- All inputs are integers.
- $1\le N \le 10000$
- $1 \le A, B \le N$
Output
Output the number of positive integers less than or equal to $N$ that satisfy the condition.
Also, print a newline at the end.
Sample
Sample 1
Input
10 3 5
Output
2
The remainders when $ 1,2,3,4,5,6,7,8,9,10 $ are divided by $3$ and $5$ are as follows.
The remainder of $1$ divided by $3$ is $1$, and divided by $5$ is $1$.
The remainder of $2$ divided by $3$ is $2$, and divided by $5$ is $2$.
The remainder of $3$ divided by $3$ is $0$, and divided by $5$ is $3$.
The remainder of $4$ divided by $3$ is $1$, and divided by $5$ is $4$.
The remainder of $5$ divided by $3$ is $2$, and divided by $5$ is $0$.
The remainder of $6$ divided by $3$ is $0$, and divided by $5$ is $1$.
The remainder of $7$ divided by $3$ is $1$, and divided by $5$ is $2$.
The remainder of $8$ divided by $3$ is $2$, and divided by $5$ is $3$.
The remainder of $9$ divided by $3$ is $0$, and divided by $5$ is $4$.
The remainder of $10$ divided by $3$ is $1$, and divided by $5$ is $0$.
Therefore, only the two values $n=5, 10$ satisfy the condition.
Sample 2
Input
1 1 1
Output
0
Sample 3
Input
2026 20 26
Output
702
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
UT0911