Project Euler 395

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

25着。15ms。
ふつうに組んだら倍々ゲームになるので答えは出ない。PCを離れて考えてみたらすぐに思いついた。