結果

問題 No.894 二種類のバス
コンテスト
ユーザー asdf1
提出日時 2019-09-27 22:22:06
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 85 ms / 1,000 ms
コード長 348 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 125 ms
コンパイル使用メモリ 77,456 KB
最終ジャッジ日時 2025-12-04 01:52:33
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

l = map(int, raw_input().split())

def gcd(a, b):
    if b > a:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

t=l[0]
a=l[1]
b=l[2]

if t%a==0:
    ans=t/a;
else:
    ans=t/a+1;

if t%b==0:
    ans+=t/b;
else:
    ans+=t/b+1;

tmp=(a * b) // gcd(a, b)

if t%tmp==0:
    ans-=t/tmp;
else:
    ans-=t/tmp+1;

print(ans);
0