#P10839. Arithmetic Operator Insertion
Arithmetic Operator Insertion
Arithmetic Operator Insertion
You are given four positive integers \(a, b, c, d\). You have an expression of the form \((a \; \Box \; b) \; \Box \; c\) where each \(\Box\) can be replaced by one of the three operators: \(+, -, \times\) (operators may be repeated).
Your task is to determine if it is possible to choose the operators such that the value of the expression equals \(d\). In other words, does there exist a pair of operators such that:
\[(a \; op_1 \; b) \; op_2 \; c = d\]
inputFormat
The input consists of a single line with four space-separated positive integers \(a\), \(b\), \(c\), and \(d\).
outputFormat
Output a single line containing YES
if it is possible to achieve \(d\) by inserting the operators correctly, or NO
otherwise.
sample
2 3 4 10
YES