結果

問題 No.751 Frac #2
ユーザー NatsubiSogan
提出日時 2020-09-22 14:06:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 383 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-26 02:27:22
合計ジャッジ時間 2,708 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
n1 = int(input())
a = list(map(int, input().split()))
n2 = int(input())
b = list(map(int, input().split()))
bumbo = 1
bunsi = a[0]
for i in range(1, n1):
    bumbo *= a[i]
for i in range(n2):
    if i % 2 == 0:
        bumbo *= b[i]
    else:
        bunsi *= b[i]
if bumbo < 0:
    bumbo *= -1
    bunsi *= -1
g = gcd(bumbo, bunsi)
print(bunsi // g, bumbo // g)
0