結果

問題 No.751 Frac #2
ユーザー YCesca
提出日時 2018-11-10 00:17:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 38 ms / 1,000 ms
コード長 472 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-11-21 07:17:27
合計ジャッジ時間 2,333 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction as fra

na=int(input())
la=list(map(int,input().split()))
nb=int(input())
lb=list(map(int,input().split()))

if na == 1:
    a=fra(la[0],1)
else:
    a=fra(la[0],la[1])
    for i in range(2,na):
        a=a*fra(1,la[i])
if nb == 1:
    b=fra(lb[0],1)
else:
    b=fra(1,1)
    for i in range(nb):
        if i% 2 == 0:
            b=b*fra(lb[i],1)
        else:
            b=b/fra(lb[i],1)
ans=a/b

print(ans.numerator, ans.denominator)




0