尼克切斯i定理(HJ76)
一:解题思路
这是一道数学题,根据数学公式可以直接算出,首项为 s=n*n-1+n;
二:完整代码示例 (C++版和Java版)
C++代码:
#include <iostream> #include <string> using namespace std; int main() { int n = 0; while (cin >> n) { int s = n * n +1 - n; cout << s; for (int i = 1; i < n; i++) cout << "+" << s + 2 * i; cout << endl; } return 0; }

浙公网安备 33010602011771号