/ SeriousOJ /

Record Detail

Accepted


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

Code

// Allah is the best planner.He knows everything
#include <bits/stdc++.h>
using namespace std;

// ordered set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type,
                         less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>
    ordered_set;

#define pb push_back
#define fast()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define en "\n"
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
    fast();

    int t = 1;
    // cin>>t;
    while (t--)
    {

        string str;
        cin >> str;
        ll count = 0;
        str.pb('+');
        ll val1 = 0, val2 = 0;
        int i = 0;
        ll n;
        cin >> n;
        while (1)
        {
            while (1)
            {
                if (str[i] == '+')
                {
                    i++;
                    break;
                }
                val1 = val1 * 10 + (str[i] - '0');
                i++;
            }

            while (1)
            {
                if (str[i] == '+')
                {
                    i++;
                    break;
                }
                val2 = val2 * 10 + (str[i] - '0');
                i++;
            }
            break;
        }

        // cout<<val1<<" "<<val2<<en;
        ll sum = val1 + val2;
        ll dif = abs(val1 - val2);
         count = 2;
        for (ll i = val2 + dif; ; i += dif)
        {
            if (count <n)
            {
                sum += i;
            }
            else 
            {
                break;
            }
            count++;
        }
        cout << sum << en;
    }
    return 0;
}
// Not a good Coder->Rifat

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:09:51
Judged At
2025-09-02 16:09:51
Judged By
Score
100
Total Time
5ms
Peak Memory
536.0 KiB