/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Wrong Answer 1ms 492.0 KiB

Code

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

int main() {
    string s;
    getline(cin, s);
    int a, b, last;

    s.erase(remove(s.begin(), s.end(), ' '), s.end());

    // Check if input contains ".."
    bool end = s.find("..") != string::npos;

    vector<int> terms;
    string temp = "";
    for (char ch : s) {
        if (isdigit(ch)) {
            temp += ch;
        } else if (ch == '+' || ch == '.') {
            if (!temp.empty()) {
                terms.push_back(stoi(temp));
                temp = "";
            }
        }
    }
    if (!temp.empty()) terms.push_back(stoi(temp)); // last number if no end

    a = terms[0];
    b = terms[1];

    cin >> last;

    int d = b - a;
    int sum = (2 * a + (last - 1) * d) * last / 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:58:11
Judged At
2025-09-02 16:58:39
Judged By
Score
10
Total Time
1ms
Peak Memory
532.0 KiB