結果

問題 No.750 Frac #1
ユーザー brthyyjpbrthyyjp
提出日時 2020-05-17 01:46:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 1,000 ms
コード長 489 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 55,708 KB
最終ジャッジ日時 2023-10-24 12:59:32
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,708 KB
testcase_01 AC 44 ms
55,708 KB
testcase_02 AC 42 ms
55,708 KB
testcase_03 AC 42 ms
55,708 KB
testcase_04 AC 43 ms
55,708 KB
testcase_05 AC 42 ms
55,708 KB
testcase_06 AC 43 ms
55,708 KB
testcase_07 AC 40 ms
55,708 KB
testcase_08 AC 41 ms
55,708 KB
testcase_09 AC 41 ms
55,708 KB
testcase_10 AC 41 ms
55,708 KB
testcase_11 AC 42 ms
55,708 KB
testcase_12 AC 40 ms
55,708 KB
testcase_13 AC 41 ms
55,708 KB
testcase_14 AC 42 ms
55,708 KB
testcase_15 AC 43 ms
55,708 KB
testcase_16 AC 43 ms
55,708 KB
testcase_17 AC 43 ms
55,708 KB
testcase_18 AC 43 ms
55,708 KB
testcase_19 AC 43 ms
55,708 KB
testcase_20 AC 41 ms
55,708 KB
testcase_21 AC 41 ms
55,708 KB
testcase_22 AC 41 ms
55,708 KB
testcase_23 AC 41 ms
55,708 KB
testcase_24 AC 42 ms
55,708 KB
testcase_25 AC 41 ms
55,708 KB
testcase_26 AC 41 ms
55,708 KB
testcase_27 AC 40 ms
55,708 KB
testcase_28 AC 42 ms
55,708 KB
testcase_29 AC 42 ms
55,708 KB
testcase_30 AC 42 ms
55,708 KB
testcase_31 AC 42 ms
55,708 KB
testcase_32 AC 42 ms
55,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
AB = []
X = []
for i in range(n):
    a, b = map(int, input().split())
    X.append(b)
    AB.append((a, b))

#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_list(X)
ans = []
for a, b in AB:
    c = a*(l//b)
    ans.append((c, a, b))

ans.sort(reverse=True)
for c, a, b in ans:
    print(a, b)
0