Project Euler 267

プロジェクトオイラー
http://projecteuler.net/index.php?section=problems&id=267

ダメだ、計算量が膨大すぎる。