P1401 [Beginner Contest #18] Do Not Multiply int by int Without Using long long
Description
In contests, it is very important to analyze the value range of variables clearly according to the Constraints. When an `int` variable is multiplied by an `int` variable, it is often possible to exceed the value range that `int` can represent.
Now, given two `int` variables $x, y$ and their value ranges, determine whether the value of $x \times y$ may exceed the range that `int` can represent.
> Hint: The range that `int` can represent is $[-2147483648, 2147483647]$, i.e. $[-2^{31}, 2^{31} - 1]$. That is, the minimum value representable by `int` is $-2147483648$, and the maximum value is $2147483647$.
Input Format
The input has two lines.
The first line contains two integers $x_l, x_u$, indicating that the value range of variable $x$ is $x_l \le x \le x_u$.
The second line contains two integers $y_l, y_u$, indicating that the value range of variable $y$ is $y_l \le y \le y_u$.
Output Format
Output one line with one string:
- If it may exceed, output `long long int`.
- If it will not exceed, output `int`.
Explanation/Hint
### Constraints
- For $50\%$ of the testdata, $0 \le x_l \le x_u < 2^{31}$, $0 \le y_l \le y_u < 2^{31}$.
- For $100\%$ of the testdata, $-2^{31} \le x_l \le x_u < 2^{31}$, $-2^{31} \le y_l \le y_u < 2^{31}$.
Translated by ChatGPT 5