結果

問題 No.751 Frac #2
ユーザー flippergo
提出日時 2024-10-23 19:35:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 336 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 54,160 KB
最終ジャッジ日時 2024-10-23 19:35:19
合計ジャッジ時間 3,754 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
N1 = int(input())
A = list(map(int,input().split()))
N2 = int(input())
B = list(map(int,input().split()))
a = A[0]
for i in range(1,N2):
    a = a*B[i]
b = B[0]
for i in range(1,N1):
    b = b*A[i]
d = gcd(a,b)
if a*b>0:
    print(a//d,b//d)
else:
    print(-abs(a//d),abs(b//d))
0