結果

問題 No.894 二種類のバス
コンテスト
ユーザー brthyyjp
提出日時 2020-05-11 04:46:46
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 53 ms / 1,000 ms
コード長 341 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 245 ms
コンパイル使用メモリ 85,112 KB
実行使用メモリ 55,168 KB
最終ジャッジ日時 2026-03-30 17:45:48
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

t, a, b = map(int, input().split())

#import fractions
import math
from functools import reduce
def lcm_base(x, y):
  #return (x * y) // fractions.gcd(x, y)
  return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

l = lcm_base(a, b)
q, r = divmod(t-1, l)
ans = q*(l//a+l//b-1)+r//a+r//b+1
print(ans)
0