S=(首项+末项)*项数/2
by Yukinoshita_Yukino @ 2019-10-15 18:13:52
```cpp
n * a1
```
by 59percent @ 2019-10-15 18:14:21
> 希望更丰富的展现?使用Markdown
by zimujun @ 2019-10-15 18:43:04
@[三十chan](/space/show?uid=267522)
#include <iostream>
using namespace std;
int main()
{
int a1, a2, n,s;
cin >> a1 >> a2 >> n;
s = n * a1 + n * (n - 1) * (a2 - a1) / 2;
cout << s<< endl;
return 0;
}
和你程序差不多,不知道为啥不对。。。
by CCCCCC11 @ 2019-10-16 20:47:36
末项=首项+(第二项-第一项)*(项数-1);
和=(首项+末项)*项数/2;
by Herbert @ 2021-03-02 20:50:45