Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
int pos = s.find('+');
long long x = stoll(s.substr(0, pos));
int pos2 = s.find('+', pos + 1);
long long y = stoll(s.substr(pos + 1, pos2 - pos - 1));
long long dif = y - x;
long long n;
cin >> n;
long long part1 = (n - 1) * x + x;
long long sum = (n * (n - 1) / 2) * dif;
sum += part1;
cout << sum << endl;
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1231 Busy Friend
- Contest
- LUCC Presents Intra LU Junior Programming Contest - Replay
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-09-02 16:09:23
- Judged At
- 2025-09-02 16:09:23
- Judged By
- Score
- 100
- Total Time
- 1ms
- Peak Memory
- 764.0 KiB