/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 4ms 452.0 KiB
#3 Accepted 4ms 532.0 KiB
#4 Accepted 4ms 320.0 KiB
#5 Accepted 4ms 344.0 KiB
#6 Accepted 4ms 532.0 KiB
#7 Accepted 4ms 320.0 KiB
#8 Accepted 4ms 532.0 KiB
#9 Accepted 4ms 532.0 KiB
#10 Accepted 4ms 532.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define nl '\n'
#define ws ' '
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007

typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vii;

signed main() {
    FASTIO
    string s;
    ll n;
    cin>>s>>n;
    vi nums;
    string tmp;
    for (char c : s) {
        if (isdigit(c)) tmp += c;
        else if (c == '+') {
            if (!tmp.empty()) {
                nums.push_back(stoll(tmp));
                tmp.clear();
            }
        }
    }
    if (!tmp.empty()) {
        nums.push_back(stoll(tmp));
    }
    ll st = nums[0];
    ll diff = nums[1] - nums[0];
    ll sum = 0;
    ll cnt = 0;
    for (ll i = st; cnt < n; i += diff) {
        cnt++;
        sum += i;
    }
    cout<<sum<<nl;
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1231 Busy Friend
Contest
Testing - Intra LU Programming contest 25
Language
C++17 (G++ 13.2.0)
Submit At
2025-08-31 07:19:55
Judged At
2025-08-31 07:19:55
Judged By
Score
100
Total Time
4ms
Peak Memory
532.0 KiB