/ SeriousOJ /

Record Detail

Accepted


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

Code

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD = 1000000007;
const int INF = 1e18;
const int N = 2e5;
//
void solve(int tc){
    string s; cin >> s;
    vector<int>gg;
    int i=0 , curr = 0;
    while(i < s.size() and s[i]!='.'){
        if(s[i] == '+'){
            gg.pb(curr);
            curr=0;
        }
        else {
            curr = (curr * 10) + (s[i]-'0');
        }
        i++;
    }
    int diff = gg[1] - gg[0];
    int n; cin >> n;
    int sum = (2 * n * gg[0] + n * (n-1) * diff) / 2;
    cout << sum << endl;
}
int32_t main(){
    Fast
    int t=1;
    // cin >> t;
    for(int tc=1;tc<=t;tc++)
        solve(tc);
    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:41:32
Judged At
2025-09-02 16:41:32
Judged By
Score
100
Total Time
4ms
Peak Memory
536.0 KiB