Project Euler 474(3)

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

いろいろ手を尽くして4分11秒になったが、もう無理かな。