题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
#include <iostream> using namespace std; int main() { int n; cin >> n; int a = 2; //首项 int sum = 2; //求和 for (int i = 1;i < n;i++) { a += 3; sum += a; } cout << sum; } // 64 位输出请用 printf("%lld")