#P1401. Multiplication Overflow in Integer Range

    ID: 14687 Type: Default 1000ms 256MiB

Multiplication Overflow in Integer Range

Multiplication Overflow in Integer Range

In programming contests, analyzing the range of variables is crucial. When multiplying two int type variables, the product may exceed the range that an int can represent.

Given two int type variables x and y along with their respective ranges, determine whether there exists a pair of values (one from each range) such that their product is out of the int range.

The range for the int type is given by \( [-2147483648,\ 2147483647] \) (i.e. \( [-2^{31},2^{31}-1] \)).

You are provided with four integers: x_min, x_max, y_min, and y_max. Consider all products of one value from \([x_{min}, x_{max}]\) with one from \([y_{min}, y_{max}]\). If any possible product is less than \(-2147483648\) or greater than \(2147483647\), output Yes; otherwise output No.

inputFormat

The input consists of a single line containing four space-separated integers: x_min x_max y_min y_max, representing the inclusive ranges for variables x and y respectively.

outputFormat

Output a single line containing either Yes or No (without quotes). Output Yes if there is at least one pair \(\{x,y\}\) with \(x\) in \([x_{min}, x_{max}]\) and \(y\) in \([y_{min},y_{max}]\) for which the product \(x \times y\) is less than \(-2147483648\) or greater than \(2147483647\); otherwise output No.

sample

1 2 3 4
No