Project Euler 28

来源:互联网 发布:主要矛盾知乎 编辑:程序博客网 时间:2024/06/03 04:42

这道题……看上去挺唬人……

其实解法很多,数学或者暴力随你……


我算是半数学吧……没大用公式,都是按照差来算的……


sum_up = 25last_max = 9#last_max is the previous circle's largest one. on the up-right corner.base = 25 #base is the base difference between last_max and the new circle's min.for circle in range(2, 501):base += 2sum_up += base*10 + last_max*4last_max += base*4print(sum_up)