题解 | #尼科彻斯定理#
尼科彻斯定理
http://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
尼科彻斯定理
Step 1 : Find the rule between output with n, found print n nums, and start = n * n - n + 1, and increase with common step
Step 2 : Coding and have a try.
#include <stdio.h>
int main()
{
int n;
while (scanf("%d", &n) != EOF) {
int start = n * n - n + 1;
printf("%d", start);
int i;
for (i = 1; i < n; i++) {
printf("+%d", start + 2 * i);
}
printf("\n");
}
return 0;
}