Product Max SOLUTION AtCoder Contest 178

Product Max SOLUTION

Problem Statement

Given are integers a,b,c and d. If x and y are integers and a≤x≤b and c≤y≤d hold, what is the maximum possible value of x×y?

Constraints

−109≤a≤b≤109

−109≤c≤d≤109

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a

b

c

d

Output

Print the answer.

Sample Input 1

Copy

1 2 1 1

Sample Output 1

Copy

2

If x=1 and y=1 then x×y=1

. If x=2 and y=1 then x×y=2

. Therefore, the answer is 2

.Sample Input 2

Copy

3 5 -4 -2

Sample Output 2

Copy

-6

The answer can be negative.

Sample Input 3

Copy

-1000000000 0 -1000000000 0

Sample Output 3

Copy

1000000000000000000

Leave a Comment