【题解】
数学题。
题意就是
a[i] + ans[i]*i = a[i+1]^2
然后移项一下
ans[i] = (a[i+1]^2-a[i])/i; ·······①
这里的ans[i]要求是整数
同时已知a[i] % i == 0
则我们要让a[i+1] % i == 0才行
构造!
构造a[i]= i*(i-1)
这样的话就能满足a[i] % i ==0 且 a[i+1] %i ==0
代入①式。
则ans[i] = (i+1)^2*i-(i-1);····③
但是还有个问题
给的初始数字是2
一开始i=1,但是a[i] = 2 不等于i*(i-1)==0
那我们就看一下i=2.
i*(i-1) == 2
而我们是可以先让第一个2加上2然后变成4.
这样a[2]就满足等于根号4等于2了。
这样a[2]就满足i*(i-1)了
那之后就简单了
a[3] = 3*(2) == 6;
。。。
那我们的③式就可以用了。
即:
第一项输出2.让a[2]满足a[2] = 2*1 ------i*(i-1)
从第二项之后直接输出ans[i];
中间计算可能会溢出要小心(long long)
【代码】
#includeint n;void input_data(){ scanf("%d", &n);}void get_ans(){ for (int i = 1; i <= n; i++) if (i == 1) printf("2\n"); else printf("%I64d\n", long long(i + 1)*(i + 1)*i - (i - 1));}int main(){ //freopen("F:\\rush.txt", "r", stdin); //freopen("F:\\rush_out.txt", "w", stdout); input_data(); get_ans(); return 0;}