結果

問題 No.751 Frac #2
ユーザー c-yan
提出日時 2020-12-07 01:20:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 368 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-17 13:31:48
合計ジャッジ時間 2,313 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce
from math import gcd

n1 = int(input())
A = list(map(int, input().split()))
n2 = int(input())
B = list(map(int, input().split()))

a = A[0] * reduce(lambda x, y: x * y, B[1::2], 1)
b = reduce(lambda x, y: x * y, A[1:], 1) * reduce(lambda x, y: x * y, B[0::2], 1)
t = gcd(a, b)
a, b = a // t, b // t
if b < 0:
    a, b = -a, -b
print(a, b)
0