結果

問題 No.894 二種類のバス
ユーザー brthyyjpbrthyyjp
提出日時 2020-05-11 04:46:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 1,000 ms
コード長 341 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 72,704 KB
最終ジャッジ日時 2023-09-23 02:33:10
合計ジャッジ時間 3,581 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
72,304 KB
testcase_01 AC 109 ms
72,560 KB
testcase_02 AC 111 ms
72,436 KB
testcase_03 AC 108 ms
72,452 KB
testcase_04 AC 110 ms
72,304 KB
testcase_05 AC 109 ms
72,644 KB
testcase_06 AC 110 ms
72,112 KB
testcase_07 AC 110 ms
72,440 KB
testcase_08 AC 108 ms
72,408 KB
testcase_09 AC 109 ms
72,300 KB
testcase_10 AC 108 ms
72,648 KB
testcase_11 AC 112 ms
72,356 KB
testcase_12 AC 109 ms
72,448 KB
testcase_13 AC 107 ms
72,404 KB
testcase_14 AC 111 ms
72,296 KB
testcase_15 AC 109 ms
72,344 KB
testcase_16 AC 110 ms
72,340 KB
testcase_17 AC 107 ms
72,496 KB
testcase_18 AC 109 ms
72,704 KB
testcase_19 AC 107 ms
72,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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