No.894 Two Types of Buses
Problem Statement
At yukicoder Station, a major station in the country of yuki, 2 buses arrive and depart. Bus 1 departs from the station every $A$ minutes, and Bus 2 departs from the station every $B$ minutes.
One day, the 2 buses departed from yukicoder Station simultaneously at time $0$.
A day in the country of yuki starts at time $0$ and ends at time $T$. Find how many times buses depart from yukicoder Station on this day. Here, if the 2 types of buses depart at the same moment, it is counted as 1 time rather than 2, and a bus departing at exactly time $T$ is not considered to have departed during this day.
Input
$T$ $A$ $B$
- A single line contains the length of a day $T$, the interval $A$ at which Bus 1 departs from the station, and the interval $B$ at which Bus 2 departs from the station, separated by spaces. $(1 \le T, A, B \le 10^{18})$
Output
Output in a single line the number of times buses depart on this day.
Do not forget the trailing newline.
Sample
Sample 1
Input
12 4 3
Output
6
Bus 1 departs from yukicoder Station 3 times, at times 0, 4, 8.
Bus 2 departs from yukicoder Station 4 times, at times 0, 3, 6, 9.
Combined, buses depart from yukicoder Station 6 times, at times 0, 3, 4, 6, 8, 9. Therefore, the answer is 6.
Sample 2
Input
17 4 6
Output
6
Bus 1 departs from yukicoder Station 5 times, at times 0, 4, 8, 12, 16.
Bus 2 departs from yukicoder Station 3 times, at times 0, 6, 12.
Combined, buses depart from yukicoder Station 6 times, at times 0, 4, 6, 8, 12, 16. Therefore, the answer is 6.
Sample 3
Input
1000000000000000000 10 25
Output
120000000000000000
Be careful of overflow.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
e869120
37zigen