Codeforces Round #372 (Div. 1) A. Plus and Square Root

,

http://codeforces.com/contest/715/problem/A

Bから解いた(しかもBを落とした)せいで点数減衰しててratingが溶けた。

solution

According to the statement, when you push the $\sqrt{x}$ button, $x = m^2k^2(k+1)^2$ holds for some $m \ge 1$. Fix $m = 1$, it’s ok. Do it.

implementation

#!/usr/bin/env python3
n = int(input())
x, k = 2, 1
while k <= n:
    y = ((k+1) * k) ** 2
    print((y - x) // k)
    x, k = (k+1) * k, k + 1