結果

問題 No.894 二種類のバス
ユーザー yansi819
提出日時 2024-05-12 13:26:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 283 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 53,916 KB
最終ジャッジ日時 2024-12-20 09:06:18
合計ジャッジ時間 2,089 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

T, A, B = map(int, input().split())
ans1 = T // A + 1 + (-1 if T % A == 0 else 0)
ans2 = T // B + 1 + (-1 if T % B == 0 else 0)
L = lcm(A, B)
ans3 = T // L + 1 + (-1 if T % L == 0 else 0)

print(ans1 + ans2 - ans3)
0