/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error 1ms 788.0 KiB
#2 Runtime Error 1ms 532.0 KiB

Code

/*
 *   BISMILLAHIR RAHMANIR RAHIM
 *   ==========================
 *
 *   Submitted By: SAKLAN
 *   North East University Bangladesh
 */

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

#define int long long
#define ll long long
#define ld long double
#define cinv(v) for(auto &i:v) cin >> i;
#define vi vector<int>
#define vii vector<ll>
#define MOD 1000000007
#define coutv(v) for(auto e:v) cout << e << ' ';
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define endl '\n'
#define saklan ios::sync_with_stdio(0); cin.tie(0);

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }



void solve(){
    int t = 1;
    //cin >> t;
    while(t--){
        string s;
        cin >> s;
        int n;
        cin >> n;


        vector<int> v;
        string temp = "";
        for(char c : s){
            if(isdigit(c)){
                temp += c;
            } else {
                if(!temp.empty()){
                    v.push_back(stoi(temp));
                    temp = "";
                }
            }
        }
        if(!temp.empty()) v.push_back(stoi(temp));

        int f = v[0];
        int second = v[1];
        int d = second - f;


        int sum = 1LL * n * (2LL * f + 1LL * (n - 1) * d) / 2;

        cout << sum << endl;
    }
}




int32_t main() {
    saklan
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    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 16:06:30
Judged At
2025-09-02 16:06:30
Judged By
Score
0
Total Time
1ms
Peak Memory
788.0 KiB