結果

問題 No.751 Frac #2
ユーザー chocorusk
提出日時 2018-11-10 08:35:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-22 10:17:02
合計ジャッジ時間 2,369 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 16 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n1=int(input())
a=list(map(int, input().split()))
a1=a[0]
a2=1
p=a[0]//abs(a[0])
for i in range(1, n1):
    a2*=abs(a[i])
    p*=(a[i]//abs(a[i]))
n2=int(input())
b1=1
b2=1
b=list(map(int, input().split()))
for i in range(n2):
    if i%2:
        b2*=abs(b[i])
    else:
        b1*=abs(b[i])
    p*=(b[i]//abs(b[i]))
c1=a1*b2
c2=a2*b1
def gcd(x, y):
    if y==0:
        return x
    return gcd(y, x%y)
g=gcd(c1, c2)
print("{} {}".format(c1//g*p, c2//g))
0