1035等差数列末项计算

 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int a1,a2,an,d,n;
 6     cin>>a1>>a2>>n;
 7     d=a2-a1;
 8     an=a1+(n-1)*d;
 9     cout<<an;
10     return 0;
11 }

这是一道数学题,有点弱鸡:

等差数列基本公式: 
末项=首项+(项数-1)×公差 
项数=(末项-首项)÷公差+1 
首项=末项-(项数-1)×公差 
和=(首项+末项)×项数÷2 
末项:最后一位数 
首项:第一位数 
项数:一共有几位数 
和:求一共数的总和

原文地址:https://www.cnblogs.com/tflsnoi/p/7966305.html