This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

17
TangDou/ShuLun/SL_18.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include <bits/stdc++.h>
using namespace std;
//给出等差数列的前两项,分别是a1,a2,问第n项是多少
int x, y, n;
int main() {
cin >> x >> y >> n;
int z = y - x;
if (n == 1) cout << x << endl;
if (n == 2) cout << y << endl;
if (n >= 3) {
for (int i = 3; i <= n; i++)y += z;
cout << x << endl;
}
return 0;
}