题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
#include <iostream>
using namespace std;
int main() {
float n;
cin >> n;
int res = (n/2) * (2*2 + (n-1)*3);
cout << res << endl;
return 0;
}
// 64 位输出请用 printf("%lld")
这道题主要考查等差数列求和公式,其中要除以的是输入的个数在计算过程中可能产生小数,所以要给予其浮点数的数据类型。
