/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 408.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 520.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 1ms 484.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define debug(x) cout << "Debug : " << x << endl;
const double PI = 2 * acos(0.0);
const int MOD = 1000000007;

void solve(){
    string s, num1, num2;
    int x;
    cin >> s >> x;

    int j = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != '+'){
            num1 += s[i];
        }
        else{
           j = i;
           break;
        }
    }

    for (int i = j + 1; i < s.size(); i++){
        if (s[i] != '+'){
            num2 += s[i];
        }
        else{
            break;
        }
    }

    ll a = stoll(num1);
    ll b = stoll(num2);

    ll dif = b - a;
    int cnt = 1;

    ll sum = 0;
    for (int i = a; i <= 1e9 && cnt <= x; i += dif){
        sum += i;
        cnt++;
    }

    cout << sum << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();
}

Information

Submit By
Type
Submission
Problem
P1231 Busy Friend
Contest
LUCC Presents Kick & Code Intra LU Programming Contest
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 05:49:19
Judged At
2025-09-01 05:49:19
Judged By
Score
100
Total Time
1ms
Peak Memory
532.0 KiB