結果
問題 | No.751 Frac #2 |
ユーザー |
![]() |
提出日時 | 2018-11-09 21:48:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 638 bytes |
コンパイル時間 | 181 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-11-21 05:49:19 |
合計ジャッジ時間 | 2,539 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 RE * 4 |
ソースコード
import fractionsimport functoolsdef main():_ = input()xs = [fractions.Fraction(int(x), 1) for x in input().split()]f = functools.reduce(lambda f1, f2: f1 / f2, xs)# print(f)_ = input()ys = [fractions.Fraction(int(x), 1) for x in input().split()]g_upper = functools.reduce(lambda f1, f2: f1 * f2, ys[::2])g_lower = functools.reduce(lambda f1, f2: f1 * f2, ys[1::2])g = g_upper / g_lower# print(g)res = f / gif res.denominator >= 0:print(res.numerator, res.denominator)else:print(-res.numerator, -res.denominator)if __name__ == '__main__':main()