#P6796. Sum of Subexpression Values

    ID: 20003 Type: Default 1000ms 256MiB

Sum of Subexpression Values

Sum of Subexpression Values

Given an expression consisting solely of digits, the '+' sign and the '*' sign, compute the sum of the values of all its subexpressions modulo $998,244,353$. A subexpression is defined as any contiguous segment of the expression that is composed of digits and the operators, and it is considered valid if its first and last characters are digits.

Each valid subexpression is evaluated using the standard operator precedence (i.e. multiplication is evaluated before addition). For example, the expression 1+2*3 evaluates to 1 + (2 * 3) = 7.

If you have any doubts, please refer to the sample explanations.

inputFormat

The input consists of a single line containing a non-empty expression made up only of digits, '+' and '*' characters.

outputFormat

Output a single integer — the sum modulo $998,244,353$ of the evaluation results of all valid subexpressions of the given expression.

sample

2+3
10