| Task: | Laskutoimitus |
| Sender: | sharph2 |
| Submission time: | 2025-12-20 16:11:36 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 20 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | ACCEPTED | 10 |
| #4 | ACCEPTED | 10 |
| #5 | RUNTIME ERROR | 0 |
| #6 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.00 s | 1, 2, 6 | details |
| #2 | RUNTIME ERROR | 0.00 s | 1, 2, 6 | details |
| #3 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5, 6 | details |
| #4 | RUNTIME ERROR | 0.00 s | 2, 6 | details |
| #5 | RUNTIME ERROR | 0.00 s | 2, 6 | details |
| #6 | ACCEPTED | 0.00 s | 2, 3, 4, 5, 6 | details |
| #7 | RUNTIME ERROR | 0.02 s | 6 | details |
| #8 | RUNTIME ERROR | 0.03 s | 6 | details |
| #9 | ACCEPTED | 0.04 s | 3, 4, 5, 6 | details |
| #10 | ACCEPTED | 0.04 s | 4, 6 | details |
| #11 | ACCEPTED | 0.04 s | 4, 6 | details |
| #12 | RUNTIME ERROR | 0.03 s | 5, 6 | details |
| #13 | RUNTIME ERROR | 0.03 s | 5, 6 | details |
Code
#include <iostream>
#include <climits>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
using namespace std;
using Z = long long int;
constexpr Z M = 1000000007;
Z mul(Z a, Z b) {
return a * b % M;
}
Z add(Z a, Z b) {
return (a + b) % M;
}
int main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
string S;
cin >> S;
Z n = S.size();
vector<Z> montaxL(n + 1);
montaxL[n] = 0;
for(Z i = 0; i < n; ++i) {
montaxL[i + 1] = montaxL[i];
if(S[i] >= '0' && S[i] <= '9') {
++montaxL[i + 1];
}
}
vector<Z> montaxR(n + 1);
montaxR[n] = 0;
for(Z i = n - 1; i >= 0; --i) {
montaxR[i] = montaxR[i + 1];
if(S[i] >= '0' && S[i] <= '9') {
++montaxR[i];
}
}
Z numerolkm = 0;
Z numerosumma = 0;
Z kerroin = 0;
//Z kokonumero = 0;
//Z kerroinsumma = 0;
Z tulos = 0;
for(Z i = 0; i < n; ++i) {
Z c = S[i];
if(c >= '1' && c <= '9') {
numerosumma = add(mul(10, numerosumma), mul(numerolkm + 1, c - '0'));
++numerolkm;
numerosumma = mul(kerroin + 1, numerosumma);
numerolkm = mul(kerroin + 1, numerolkm);
kerroin = 0;
} else if(c == '+') {
tulos = add(tulos, mul(montaxR[i], numerosumma));
kerroin = montaxL[i];
numerolkm = 0;
numerosumma = 0;
} else if(c == '*') {
throw 5;
} else {
throw 5;
}
tulos = add(tulos, numerosumma);
}
cout << tulos << "\n";
return 0;
}
Test details
Test 1
Group: 1, 2, 6
Verdict: RUNTIME ERROR
| input |
|---|
| *3*7*5+67*2*7*12+38*4+9+2+1+45... |
| correct output |
|---|
| 665527462 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 2
Group: 1, 2, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 84149523195388144+1*8*5*1722+5... |
| correct output |
|---|
| 572374284 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 3
Group: 1, 2, 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 347358248955243114242997746491... |
| correct output |
|---|
| 823495931 |
| user output |
|---|
| 823495931 |
Test 4
Group: 2, 6
Verdict: RUNTIME ERROR
| input |
|---|
| +4976829*6+5+9*21+4*889+6*7+4*... |
| correct output |
|---|
| 503712700 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 5
Group: 2, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 862+83782+493135426+3152859674... |
| correct output |
|---|
| 624304680 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 6
Group: 2, 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 297736662651354417265929591745... |
| correct output |
|---|
| 625284593 |
| user output |
|---|
| 625284593 |
Test 7
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| +9+1+8+92*761+68*983*1+7*1+1*2... |
| correct output |
|---|
| 947469815 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 8
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 97831833*7+4229897789494398634... |
| correct output |
|---|
| 173934151 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 9
Group: 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 777551563653223263644973172313... |
| correct output |
|---|
| 278364064 |
| user output |
|---|
| 278364064 |
Test 10
Group: 4, 6
Verdict: ACCEPTED
| input |
|---|
| +481+4+66+2+26+7+5+97+6+4+3+14... |
| correct output |
|---|
| 244847224 |
| user output |
|---|
| 244847224 |
Test 11
Group: 4, 6
Verdict: ACCEPTED
| input |
|---|
| +8858717+53+6927+314+742552843... |
| correct output |
|---|
| 928369840 |
| user output |
|---|
| 928369840 |
Test 12
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| *7*75*59*7*9*74*4*18211*31*1*7... |
| correct output |
|---|
| 219382651 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
Test 13
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 73171*3438*9*34165158853*375*7... |
| correct output |
|---|
| 451362612 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'int'
