結果

問題 No.751 Frac #2
ユーザー hedwig100hedwig100
提出日時 2020-04-26 10:59:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-27 21:41:05
合計ジャッジ時間 2,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,880 KB
testcase_01 AC 26 ms
11,008 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 WA -
testcase_04 AC 24 ms
10,880 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 26 ms
10,880 KB
testcase_08 WA -
testcase_09 AC 24 ms
10,752 KB
testcase_10 AC 25 ms
10,880 KB
testcase_11 AC 25 ms
10,880 KB
testcase_12 AC 25 ms
10,880 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 29 ms
10,880 KB
testcase_16 AC 25 ms
10,880 KB
testcase_17 AC 24 ms
11,008 KB
testcase_18 WA -
testcase_19 AC 25 ms
10,880 KB
testcase_20 AC 24 ms
10,880 KB
testcase_21 WA -
testcase_22 AC 24 ms
10,880 KB
testcase_23 AC 24 ms
10,880 KB
testcase_24 AC 24 ms
10,880 KB
testcase_25 AC 25 ms
10,880 KB
testcase_26 AC 25 ms
10,880 KB
testcase_27 AC 27 ms
10,880 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 25 ms
10,880 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 24 ms
10,880 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 9
MOD = 10 **9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import gcd

def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = int(input())
    b = list(map(int,input().split()))

    if n%2 == 0:
        child = a[0]
        mother = 1
        for i in range(1,n):
            mother *= a[i]
        for i in range(m):
            if m%2 == 0:
                child *= b[i]
            else:
                mother *= b[i]
        if child < 0 and mother < 0:
            child *= -1
            mother *= -1
        elif child > 0 and mother < 0:
            child *= -1
            mother *= -1
        g = gcd(child,mother)
        print(child//g,mother//g)
    
    else:
        child = a[0]
        mother = 1
        for i in range(1,n):
            mother *= a[i]
        for i in range(m):
            if i%2 == 0:
                mother *= b[i]
            else:
                child *= b[i]
        if child < 0 and mother < 0:
            child *= -1
            mother *= -1
        elif child > 0 and mother < 0:
            child *= -1
            mother *= -1
        g = gcd(child,mother)
        print(child//g,mother//g)

if __name__=='__main__':
    main()
0