/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 528.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 2ms 532.0 KiB
#10 Accepted 3ms 552.0 KiB

Code

/*
    Author: abdmahdi56
*/
#include <bits/stdc++.h>
#define endl '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define vi vector<ll>
#define all(v) v.begin(), v.end()
#define loop(n) for(int i = 0; i < (n); i++)

using namespace std;

void Bismillah() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void solve() {
    string s;
    cin>>s;
    ll n;
    cin>>n;
    stringstream ss(s);
    ll a,b;
    char c='+';
    ss>>a>>c>>b;
    ll d=b-a;

    ll ans=(n*(2*a+(n-1)*d))/2;
    cout<<ans;

}
int main() {
    Bismillah();
    int t=1;
    //cin >> t;
    while (t--) {
        solve();
    }
    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:31:20
Judged At
2025-09-02 15:31:20
Judged By
Score
100
Total Time
3ms
Peak Memory
552.0 KiB