Project Euler 366

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

やっと728が出た。でも本番はここから。
やっとできた。43着。パッと見よりも易しかった。