P10839 [MX-J2-T0] Turtle and Equations
Background
Original problem link: .
Description
You are given four positive integers $a, b, c, d$.
Now you have an expression $(a\ \Box\ b)\ \Box\ c$. You need to determine whether it is possible to fill each of the two boxes with one of the three operators $+, -, \times$ (operators may be reused) so that the value of the expression equals $d$.
Input Format
The first line contains four positive integers $a, b, c, d$.
Output Format
If it is possible to make the result equal to $d$, output `Yes`; otherwise output `No`.
Explanation/Hint
#### Sample Explanation #1
Because $(1 + 1) + 1 = 3$, you can put $+$ in the first box and $+$ in the second box.
#### Sample Explanation #2
Because $(5 - 2) \times 9 = 27$, you can put $-$ in the first box and $\times$ in the second box.
#### Sample Explanation #3
No matter which operators you choose, you cannot make the result of the expression equal to $514$.
#### Constraints
For all testdata, $1 \le a, b, c \le 10$ and $1 \le d \le 1000$.
Translated by ChatGPT 5