結果

問題 No.751 Frac #2
ユーザー htkbhtkb
提出日時 2018-12-01 16:09:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 529 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-09-09 06:50:50
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 15 ms
7,768 KB
testcase_02 AC 17 ms
7,772 KB
testcase_03 AC 17 ms
7,788 KB
testcase_04 RE -
testcase_05 AC 16 ms
7,868 KB
testcase_06 AC 15 ms
7,860 KB
testcase_07 RE -
testcase_08 AC 16 ms
7,804 KB
testcase_09 RE -
testcase_10 AC 16 ms
7,844 KB
testcase_11 WA -
testcase_12 RE -
testcase_13 AC 16 ms
7,784 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 WA -
testcase_18 AC 16 ms
7,932 KB
testcase_19 RE -
testcase_20 AC 16 ms
7,748 KB
testcase_21 WA -
testcase_22 AC 16 ms
7,868 KB
testcase_23 AC 16 ms
7,864 KB
testcase_24 AC 16 ms
7,872 KB
testcase_25 AC 15 ms
7,744 KB
testcase_26 WA -
testcase_27 RE -
testcase_28 AC 16 ms
7,876 KB
testcase_29 AC 15 ms
7,780 KB
testcase_30 WA -
testcase_31 RE -
testcase_32 AC 15 ms
7,788 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

input()
numerator = list(map(int, input().split()))
input()
denominator = list(map(int, input().split()))

while len(numerator) > 2:
    numerator[2] *= numerator[1]
    numerator.pop(1)
while len(denominator) > 2:
    denominator[-3] *= denominator[-1]
    denominator.pop()

numerator, denominator = numerator[0]*denominator[1], numerator[1]*denominator[0]
if denominator < 0:
    numerator *= -1
    denominator *= -1

gcd, _ = denominator, numerator
while _ > 0:
    gcd, _ = _, gcd%_

print(numerator//gcd, denominator//gcd)
0