/ SeriousOJ /

Record Detail

Accepted


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

Code

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using OrderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define v vector
#define int long long
#define vin vector <int>
#define pii pair <int, int>
#define all(a) a.begin(), a.end()
#define yes cout << "YES\n"
#define Yes cout << "Yes\n"
#define no cout << "NO\n"
#define No cout << "No\n"
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repn(i, a, b) for(int i = a; i <= b; i++)
#define rev(i, a, b) for(int i = a; i >= b; i--)
int mod = 998244353;

void fastIO(){
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

void pk() {
    string x; cin >> x;
    int i = 0, a = 0, b = 0; 
    while(x[i] >= '0' and x[i] <= '9'){
        a *= 10; a += x[i]-'0'; i++;
    } i++;
    while(x[i] >= '0' and x[i] <= '9'){
        b *= 10; b += x[i]-'0'; i++;
    }
    int d = b-a;
    int n; cin >> n;
    cout << ((2*a + (n-1)*d)*n)/2 ;
}

int32_t main(){
    fastIO();
    int t = 1;
    // cin >> t;
    while(t--) pk();
    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:01:32
Judged At
2025-09-02 16:01:32
Judged By
Score
100
Total Time
4ms
Peak Memory
536.0 KiB