Advanced arithmetic
Some of the more complex formulas require some operations to be performed first, and others afterward. In math, we prioritize them with parentheses.
In this formula,
a + b - c
needs to be performed before the multiplication, and the subtraction of 2
needs to happen in the end.In math, the top priority is given to parentheses, then exponentiation, then multiplication or division, then addition or subtraction.
Python follows the same priority order. The order of priorities for arithmetic operations is:
- Parentheses
- Exponentiation
- Multiplication and division
- Addition and subtraction
Knowing this, your task is to calculate a complex formula, given
a
and b
integers as an input:Print the value of
y
in the output.Input | Output |
3
4 | 16 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB