/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Runtime Error 1ms 536.0 KiB
#3 Runtime Error 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    getline(cin, s);
    int a[100], count = 0;
    string temp = "";
    for(int i = 0; i < s.length(); i++){
        char ch = s[i];
        if(isdigit(ch)){
            temp = temp + ch;
        }
        else{
            if(temp != ""){
                a[count] = stoi(temp);
                count++;
                temp = "";
            }
        }
        if(count == 2){
            break;
        }
    }
    long long sum = 0, diff = a[1] - a[0], n;
    cin >> n;
    for(int i = 2; i < n; i++){
       a[i] = a[i-1] + diff;
    }
    for(int i = 0; i < n; i++){
       sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1231 Busy Friend
Contest
LUCC Presents Intra LU Junior Programming Contest - Replay
Language
C++11 (G++ 13.2.0)
Submit At
2025-09-02 17:09:16
Judged At
2025-09-02 17:09:16
Judged By
Score
10
Total Time
1ms
Peak Memory
536.0 KiB