結果
| 問題 |
No.750 Frac #1
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2020-05-17 01:46:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 1,000 ms |
| コード長 | 489 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 56,552 KB |
| 最終ジャッジ日時 | 2024-09-23 05:20:00 |
| 合計ジャッジ時間 | 2,840 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
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)
brthyyjp