题解 | #尼科彻斯定理#
尼科彻斯定理
https://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
#include <stdio.h> #include <string.h> int main(){ int n; scanf("%d", &n); int squ = n * n; int sun; if(squ % 2 == 0){ int first = squ - (n / 2) * 2 + 1; printf("%d", first); for(int i = 1; i < n; i++){ sun = first + i * 2; printf("+%d", sun); } } else { int first = squ - (n - 1); printf("%d", first); for(int j = 1; j < n; j++){ sun = first + j * 2; printf("+%d", sun); } } return 0; }