Project Euler 394(2)

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

今朝考え直して、分割数Nとして計算量がO(N2)からO(N)になった。これでインチキしなくても20秒で収束した。