結果

問題 No.751 Frac #2
ユーザー lloyz
提出日時 2022-05-10 00:48:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 403 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-07-17 05:55:28
合計ジャッジ時間 2,666 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

n1 = int(input())
A = list(map(int, input().split()))
numerator = A[0]
denominator = 1
for i in range(1, n1):
    denominator *= A[i]
n2 = int(input())
B = list(map(int, input().split()))
denominator *= B[0]
for i in range(1, n2):
    numerator *= B[i]
gcd_n = gcd(numerator, denominator)
if denominator // gcd_n < 0:
    gcd_n *= -1
print(numerator // gcd_n, denominator // gcd_n)
0