Project Euler 417(2)

http://projecteuler.net/index.php?section=problems&id=417

ちょっと工夫したら2分半になった。80倍くらい速くなった。