結果

問題 No.280 歯車の問題(1)
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-09-19 13:22:20
言語 Python2
(2.7.18)
結果
AC  
実行時間 25 ms / 1,000 ms
コード長 1,469 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 6,588 KB
実行使用メモリ 7,816 KB
最終ジャッジ日時 2023-09-26 13:34:14
合計ジャッジ時間 5,030 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
7,816 KB
testcase_01 AC 23 ms
7,704 KB
testcase_02 AC 23 ms
7,776 KB
testcase_03 AC 23 ms
7,684 KB
testcase_04 AC 24 ms
7,596 KB
testcase_05 AC 23 ms
7,708 KB
testcase_06 AC 24 ms
7,736 KB
testcase_07 AC 24 ms
7,772 KB
testcase_08 AC 24 ms
7,748 KB
testcase_09 AC 24 ms
7,600 KB
testcase_10 AC 24 ms
7,772 KB
testcase_11 AC 24 ms
7,652 KB
testcase_12 AC 25 ms
7,660 KB
testcase_13 AC 23 ms
7,600 KB
testcase_14 AC 24 ms
7,740 KB
testcase_15 AC 23 ms
7,752 KB
testcase_16 AC 23 ms
7,652 KB
testcase_17 AC 24 ms
7,652 KB
testcase_18 AC 23 ms
7,640 KB
testcase_19 AC 24 ms
7,768 KB
testcase_20 AC 24 ms
7,656 KB
testcase_21 AC 24 ms
7,652 KB
testcase_22 AC 24 ms
7,596 KB
testcase_23 AC 24 ms
7,636 KB
testcase_24 AC 24 ms
7,796 KB
testcase_25 AC 24 ms
7,652 KB
testcase_26 AC 24 ms
7,748 KB
testcase_27 AC 24 ms
7,760 KB
testcase_28 AC 23 ms
7,640 KB
testcase_29 AC 23 ms
7,652 KB
testcase_30 AC 23 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
from operator import mul
from fractions import Fraction
from itertools import izip, tee

class MyFraction(Fraction):
    from operator import add, sub, mul, div
    def __add__(self, other):  return MyFraction(reduce(add, map(Fraction, (self, other))))
    def __radd__(self, other): return MyFraction(reduce(add, map(Fraction, (other, self))))
    def __sub__(self, other):  return MyFraction(reduce(sub, map(Fraction, (self, other))))
    def __rsub__(self, other): return MyFraction(reduce(sub, map(Fraction, (other, self))))
    def __mul__(self, other):  return MyFraction(reduce(mul, map(Fraction, (self, other))))
    def __rmul__(self, other): return MyFraction(reduce(mul, map(Fraction, (other, self))))
    def __div__(self, other):  return MyFraction(reduce(div, map(Fraction, (self, other))))
    def __rdiv__(self, other): return MyFraction(reduce(div, map(Fraction, (other, self))))
    def __pow__(self, other):  return MyFraction(reduce(pow, map(Fraction, (self, other))))
    def __rpow__(self, other): return MyFraction(reduce(pow, map(Fraction, (other, self))))
    def __str__(self): return '{}/{}'.format(self.numerator, self.denominator)
    def __repr__(self): return 'MyFraction {}/{}'.format(self.numerator, self.denominator)

def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)

raw_input()
print reduce(mul, map(lambda (x, y): MyFraction(y, x), pairwise(map(int, raw_input().split()))))
0