#P1689. 方程求解

方程求解

Description

Given an equation of the form X+Y=ZX+Y=Z or XY=ZX-Y=Z. Among XX, YY, and ZZ, two values are given, and the remaining one is represented by ?. Compute the value of ?. There may be extra spaces in the equation.

Input Format

The input consists of a single line containing a string representing the equation.

Output Format

Output one integer on a single line, which is the value represented by ?.

1+2=?

3

3 +? =  2

-1
3-?=2

1

Hint

Constraints: For 100%100\% of the testdata, it is guaranteed that 0X,Y,Z<1090 \le X, Y, Z \lt 10^9, the input string always conforms to the specified format, and its length does not exceed 10610^6.

Translated by ChatGPT 5