Your solution takes quite a long time to run (more than a minute, anyway). Is there a time limit imposed by the judge on the time that may be required to resolve?
Also, if you use Python 3, then the split operator ( /= ) always produces a floating point result. In Python 2, the result will be truncated by an integer with integer inputs.
Actually, with Python 3, I get an overflow error:
Traceback (most recent call last): File "<stdin>", line 2, in <module> File "<stdin>", line 6, in P OverflowError: int/int too large for a float
Greg hewgill
source share