Accepted
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
/*
OBSERVATIONS:
*/
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
vector<int> arr;
string num;
for (char ch : s)
{
if (isdigit(ch))
{
num += ch;
}
else
{
if (!num.empty())
{
arr.push_back(stoll(num));
num = "";
}
}
}
int n;
cin >> n;
int res = arr[0];
int d = arr[1] - arr[0];
int prev = res;
for (int i = 1; i < n; i++)
{
int newele = prev + d;
res += newele;
prev = newele;
}
cout << res << 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 15:59:56
- Judged At
- 2025-09-02 15:59:56
- Judged By
- Score
- 100
- Total Time
- 4ms
- Peak Memory
- 536.0 KiB