結果

問題 No.751 Frac #2
ユーザー kohei2019
提出日時 2022-04-05 23:27:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 457 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 52,608 KB
最終ジャッジ日時 2024-11-27 08:30:40
合計ジャッジ時間 2,887 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N1 = int(input())
lsA = list(map(int,input().split()))
N2 = int(input())
lsB = list(map(int,input().split()))
lsc = lsA[0]
lsp = 1
for i in range(1,N1):
    lsp *= lsA[i]
for i in range(N2):
    if i % 2 == 0:
        lsp *= lsB[i]
    else:
        lsc *= lsB[i]
gcd = math.gcd(lsc, lsp)
if lsc*lsp < 0:
    print(-abs(lsc//gcd),abs(lsp//gcd))
elif lsc < 0 and lsp < 0:
    print(abs(lsc//gcd),abs(lsp//gcd))
else:
    print(lsc//gcd,lsp//gcd)
0