题解 | 尼科彻斯定理
尼科彻斯定理
https://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
#include<iostream>
#include<string>
using namespace std;
int main() {
int m;
while (cin >> m) {
int odd = m * m - (m - 1); //根据公式获取起点奇数
cout << odd;
for (int i = 1; i < m; i++) //遍历后续m-1个奇数
cout << '+' << odd + 2 * i; //输出
cout << endl;
}
return 0;
}
查看2道真题和解析