/* 公式: 末项=首项+(项数-1)*公差 项数=(末项-首项)/公差+1 首项=末项-(项数-1)* 公差 和=(首项+末项)*项数/2 */ #include<bits/stdc++.h> using namespace std; int main(){ int a1,a2,n; scanf("%d%d%d",&a1,&a2,&n); printf("%d",a1+(a2-a1)*(n-1));//末项=首项+(项数-1)*公差 return 0; }
注册一个 Hydro 通用账户,您就可以在我们提供的所有在线评测服务上提交代码、参与讨论。
使用您的 Hydro 通用账户