You are on page 1of 1

15/11/2020 Easy Arithmetic – Kattis, ICPC Vietnam National Programming Contest 2020

Problem ID: vietnam-

Problem E
national20.easyarithmetic
CPU Time limit: 2 seconds

Easy Arithmetic Memory limit: 1024 MB

Harry is now a third-year student at Hogwarts School of Witchcraft and Wizardry. Contrary to popular belief, arithmetic
(known as Arithmancy in the wizard world) is crucial to becoming a powerful wizard.

For today’s Arithmancy homework, Harry is given a super long expression s of length n, containing digits, the + and -
operators. The i-th (1 ≤ i ≤ n) character of s is denoted by si .

Harry must answer q queries of the following two types:

1. ? ℓ r: Compute the value of the expression from the ℓ-th character to the r -th character, inclusive. As the value of this
expression can be very large, Harry must calculate it modulo 998 244 353 .

2. ! i c: Change si to the character c .

Please help Harry!

Input
The rst line contains n characters representing the expression s (1 ≤ n ≤ 10 ) .
5
It is guaranteed that all characters are
either digits or the + and - operators, and no two consecutive characters in s are operators.

The second line contains q (1 ≤ q ≤ 10 ) .


5

In the next q lines, each line contains one query:

? ℓ r (1 ≤ ℓ ≤ r ≤ n): representing a query of the rst type. It is guaranteed that sr is a digit.

! i c (1 ≤ i ≤ n) , c is either a digit or + or -: representing a query of the second type. It is guaranteed that after this
query, no two consecutive characters are operators.

Output
For each query of the rst type, print the value of the expression, modulo 998 244 353 .

Sample Input 1 Sample Output 1


123-456+789 19
10 13
? 2 5 998244308
? 7 9 230456
? 4 6 998244330
! 1 + 456
! 4 0 4
? 1 7
! 1 -
? 1 3
? 4 7
? 4 5

https://vietnam-national20.kattis.com/problems/vietnam-national20.easyarithmetic 1/1

You might also like