#include<bits/stdc++.h> #define int long long usingnamespacestd; constint P = 10000; string s;
intcalc(int l, int r) { if(l > r) return0; stringstreamss(s.substr(l, r - l + 1)); int base; ss >> base; char c; int xx; while(ss >> c >> xx) { xx = xx % P; if(c == '*') base = base * xx % P; } // printf("calc(%d, %d) = %d\n", l, r, base); return base; }
signedmain(void) { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); // cin >> s; getline(cin, s); int lastpos = 0, ans = 0; for(int i = 0; i < s.length(); i ++) { if(s[i] == '+') ans += calc(lastpos, i - 1), ans = ans % P, lastpos = i + 1; } ans = ans + calc(lastpos, s.length() - 1); printf("%d", ans); }
#include<bits/stdc++.h> #define int long long usingnamespacestd; constint P = 10000; string s;
intcalc(int l, int r) { if(l > r) return0; stringstreamss(s.substr(l, r - l + 1)); int base; ss >> base; char c; int xx; while(ss >> c >> xx) { xx = xx % P; if(c == '*') base = base * xx % P; } // printf("calc(%d, %d) = %d\n", l, r, base); return base; }
signedmain(void) { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); // cin >> s; getline(cin, s); int lastpos = 0, ans = 0; for(int i = 0; i < s.length(); i ++) { if(s[i] == '+') ans += calc(lastpos, i - 1), ans = ans % P, lastpos = i + 1; } ans = (ans + calc(lastpos, s.length() - 1)) % P; printf("%d", ans % P); }