/ 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 2ms 532.0 KiB
#5 Accepted 3ms 532.0 KiB
#6 Accepted 3ms 532.0 KiB
#7 Accepted 4ms 532.0 KiB
#8 Accepted 4ms 532.0 KiB
#9 Accepted 4ms 532.0 KiB
#10 Accepted 4ms 764.0 KiB

Code

// @rakibul-islam

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
const ll oo = 1e17;

// 1 + 3 + 5 + 7 + 9

int main() {
  cin.tie(0)->sync_with_stdio(0);
  string s; cin >> s;
  int n;  cin >> n;
  ll fst = 0, snd = 0;
  int i = 0;
  while (s[i] != '+') {
    fst *= 10;
    fst += int(s[i] - '0');
    i++;
  }
  i++;
  while (s[i] != '+') {
    snd *= 10;
    snd += int(s[i] - '0');
    i++;
  }
  ll dif = (snd - fst);
  ll add = dif * (n - 1);
  ll N = fst + add;
  ll sum = n * (fst + N);
  sum /= 2;
  cout << sum << "\n";
  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:55:04
Judged At
2025-09-02 16:55:04
Judged By
Score
100
Total Time
4ms
Peak Memory
764.0 KiB