P26686 [AtCoder] Vector Expression
提高+
题目描述

Problem Description

Given a vector expression $ S $ represented by the following BNF, compute it.

```
<expr> ::= <number> | "("<expr>""<expr>")" | "("<vector>""<vector>")"
<vector> ::= "("<expr>","<expr>")" | "("<expr>""<vector>")" | "("<vector>""<expr>")"
<number> ::= <digit> | <number><digit>
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"


The value of `<expr>` is an integer (scalar), and the value of `<vector>` is a two-dimensional vector. The operator `*` has the following meanings in this problem:

- For `<expr>` with `<expr>`: represents the product of integers.
- For `<vector>` with `<vector>`: represents the dot product of vectors.
- For `<expr>` with `<vector>`: represents scalar multiplication of a vector.

However, the answer can be very large, so output it modulo $ 998244353 $.

## Input Format

The input is given from the standard input in the following format:

> $ S $

## Output Format

Output the result of the expression modulo $ 998244353 $.

## Sample Input and Output

### Sample Input #1

((1,2)*(3,4))


### Sample Output #1

11


### Sample Input #2

((((12),3)4)(((5,6)(7,8))*(9,10)))


### Sample Output #2

15936


### Sample Input #3

0000000000099824435399824435399824435399824435399824435398


### Sample Output #3

98
```

Notes/Hints

Constraints

  • $ 1≦|S|≦10^5 $
  • $ S $ is an expression represented by the <expr> in the problem's BNF.

Sample Explanation 1

The dot product of vector $ (1,2) $ and vector $ (3,4) $ is calculated as $ 1*3 + 2*4 = 11 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
((1,2)*(3,4))
样例输出
11