P6796 "StOI-2" Many Expressions

Background

This problem is the first problem of the second open contest of [StOI](https://www.luogu.com.cn/team/24701), [StOI Round2](https://www.luogu.com.cn/contest/32483). __Note: If this number has multiple digits, it will not be split apart.__ By LHQing, 14:09. :)

Description

Given an expression consisting only of digits, `+`, and `*`, find the sum of the values of all its subexpressions, modulo $998,244,353$. A subexpression of an expression is defined as an expression formed by `a consecutive segment of numbers and the operators between them`. If you still cannot understand, **you can refer to the sample explanation**.

Input Format

The first line contains a positive integer $n$, which denotes the number of numbers in the expression. The next line contains the expression consisting of $n$ positive integers and $n - 1$ operators, with spaces between numbers and operators.

Output Format

Output one number, which is the final answer.

Explanation/Hint

# Sample Explanation The given expression has a total of six subexpressions: $1$, $2$, $3$, $1+2$, $2 \times 3$, $1+2 \times 3$. Their values are $1$, $2$, $3$, $3$, $6$, $7$, and the sum is $22$. --- # Constraints For $20\%$ of the testdata: $1 \leq n \leq 1000$. For another $20\%$ of the testdata: there is no `+`. For another $20\%$ of the testdata: there is only one `+`. For another $20\%$ of the testdata: there is only one `*`. For $100\%$ of the testdata: $1 \leq n \leq 10^{5}$, all numbers are at most $10^{9}$, and the operators only include `+` and `*`. # Output Format Translated by ChatGPT 5