# | Problem | Pass Rate (passed user / total user) |
---|---|---|
14290 | 2024_IDS_Spring_Lab6_Calculator |
|
Description
You have an arithmetic expression that contains at most 5 variables A - E , binary operators '+', '-', '*', '/', where the '/' denotes integer division, and brackets '(', ')'. Given the values for the variables, please calculate the answer.
Note: Here we define integer division as the integer part of division (not rounding down). For example, 8 divided by 7 under division is 1.1428..., so 8 divided by 7 under integer division will be 1. -8 divided by 7 is -1.1428..., so -8 divided by 7 under integer division will be -1 (instead of -2).
Input
The first line is the arithmetic expression.
The second line is an integer T.
In the following T lines, each line has 5 integers: the values for variable A to E.
Constraints
- 1 <= T <= 10
- Length of arithmetic expression <= 200,000
- -1,000,000,000 <= The intermediate values during calculation <= 1,000,000,000
- Division by zero will not happen during calculation
Output
Output T lines, each line is the answer to a set of values for variable A to E.
Output Format
There's no \n on the last output line!
[Answer 1]\n
[Answer 2]\n
...
[Answer T]