2 5 8 11 ...的等差数列
输入:n
输出:前n项的和
#include <iostream>
using namespace std;
static int total=0;
int diff(int n)
{
if (n > 0)
{
total = (3 * n*n + n) / 2;
return 0;
}
else return -1;
}
int main()
{
int N;
cin >> N;
diff(N);
cout << total << endl;
return 0;
}