/ SeriousOJ /

Record Detail

Accepted


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

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