結果

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

ソースコード

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,2):
    a = a*B[i]
b = B[0]
for i in range(1,N1):
    b = b*A[i]
for i in range(2,N2,2):
    b = b*B[i]
d = gcd(a,b)
if a*b>0:
    print(a//d,b//d)
else:
    print(-abs(a//d),abs(b//d))
0