You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
383 B

2 years ago
#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;
}