/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 596.0 KiB
#3 Accepted 1ms 404.0 KiB
#4 Accepted 1ms 752.0 KiB
#5 Accepted 1ms 764.0 KiB
#6 Accepted 1ms 536.0 KiB
#7 Accepted 1ms 632.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 548.0 KiB
#10 Accepted 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
// const int MOD = 998244353;
const int N = 1e6 + 9;
//    const uint M=(1<<31)

// int pref_xor[N];

// int a[N];
// int cnt[30][2];
//    vector<int>v(n);
//    bitset<M>a;

// vector<int> v(n + 1);
// bool vis[N];

void pari_na_kisu()

{
    string s;
    cin >> s;
    int n;
    cin >> n;
    int x, x1;
    int pos = 0;
    string k, t;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '+')
        {
            pos = i;
            break;
        }
        else
        {
            k += s[i];
        }
    }
    for (int i = pos + 1; i < s.size(); i++)
    {
        if (s[i] == '+')
        {
            break;
        }
        else
        {
            t += s[i];
        }
    }
    x = stoll(k);
    x1 = stoll(t);
    int d = x1 - x;

    int z = (2 * x) + ((n - 1) * d);
    int res = ((n * z) / 2);
    // cout<<x<<' '<<x1<<' '<<d<<" "<<z<<'\n';
    cout << res << '\n';
}

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

    // cout << "Case " << (++cs) << ": ";
    pari_na_kisu();
}

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:57:50
Judged At
2025-09-02 16:58:39
Judged By
Score
100
Total Time
1ms
Peak Memory
764.0 KiB