結果

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

ソースコード

diff #

n1=int(input())
a=list(map(int,input().split()))
n2=int(input())
b=list(map(int,input().split()))

up=1
down=1

def gcd(a, b):
    if(a%b==0):
        return b
    else:
        return gcd(b, a%b)

for i in range(n1):
    if i==0:
        up*=a[i]
    else:
        down*=a[i]

for i in range(n2):
    if i%2==0:
        down*=b[i]
    else:
        up*=b[i]

if up<0 and down<0:
    up=-up
    down=-down

d=gcd(up,down)
up//=d
down//=d

print(str(up)+" "+str(down))
0