Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int mod = 1e9 + 7;
- int main() {
- long long q, num;
- cin >> num >> q;
- long long res = num;
- int offset = 0;
- for (int i = 0; i < q; i++) {
- char c;
- cin >> c;
- if (c == '+')
- {
- int d;
- cin >> d;
- if (num >= 1e11)
- {
- res *= 10;
- res += d;
- res %= mod;
- offset++;
- }
- else
- {
- num *= 10;
- num += d;
- res = num % mod;
- }
- }
- else {
- if (offset)
- {
- res /= 10;
- res %= mod;
- offset--;
- }
- else
- {
- num /= 10;
- res = num % mod;
- }
- }
- cout << res << '\n';
- }
- //system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement