問題一覧 > 通常問題

No.894 Two Types of Buses

レベル : / AI推定難易度 : 750 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 256 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 295
作問者 : e869120 / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 1692 / 自分の提出
問題文最終更新日: 2019-09-27 21:15:44
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 225 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。