結果
問題 | No.280 歯車の問題(1) |
ユーザー | yuppe19 😺 |
提出日時 | 2015-09-19 13:22:20 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 24 ms / 1,000 ms |
コード長 | 1,469 bytes |
コンパイル時間 | 48 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-07-19 07:54:20 |
合計ジャッジ時間 | 3,521 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
8,064 KB |
testcase_01 | AC | 23 ms
7,936 KB |
testcase_02 | AC | 23 ms
8,064 KB |
testcase_03 | AC | 23 ms
7,936 KB |
testcase_04 | AC | 22 ms
8,064 KB |
testcase_05 | AC | 22 ms
7,936 KB |
testcase_06 | AC | 21 ms
8,064 KB |
testcase_07 | AC | 23 ms
7,936 KB |
testcase_08 | AC | 23 ms
8,064 KB |
testcase_09 | AC | 21 ms
7,936 KB |
testcase_10 | AC | 22 ms
7,936 KB |
testcase_11 | AC | 22 ms
7,936 KB |
testcase_12 | AC | 22 ms
7,936 KB |
testcase_13 | AC | 22 ms
7,936 KB |
testcase_14 | AC | 22 ms
8,064 KB |
testcase_15 | AC | 22 ms
7,936 KB |
testcase_16 | AC | 23 ms
8,064 KB |
testcase_17 | AC | 21 ms
7,936 KB |
testcase_18 | AC | 22 ms
7,936 KB |
testcase_19 | AC | 23 ms
7,936 KB |
testcase_20 | AC | 21 ms
8,064 KB |
testcase_21 | AC | 21 ms
7,936 KB |
testcase_22 | AC | 22 ms
7,936 KB |
testcase_23 | AC | 22 ms
7,936 KB |
testcase_24 | AC | 22 ms
8,064 KB |
testcase_25 | AC | 22 ms
7,936 KB |
testcase_26 | AC | 22 ms
7,936 KB |
testcase_27 | AC | 21 ms
7,936 KB |
testcase_28 | AC | 22 ms
8,064 KB |
testcase_29 | AC | 22 ms
7,936 KB |
testcase_30 | AC | 22 ms
8,064 KB |
ソースコード
#!/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()))))