AtCoder Beginner Contest 178 - Product Max

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

-----Constraints-----
 - -10^9 \leq a \leq b \leq 10^9
 - -10^9 \leq c \leq d \leq 10^9
 - 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 2 1 1

-----Sample Output-----
2

If x = 1 and y = 1 then x \times y = 1.
If x = 2 and y = 1 then x \times y = 2.
Therefore, the answer is 2.

Difficulty: EASY

Starter code:

Solutions:
[a, b, c, d] = list(map(int, input().split()))
if a > 0 and d < 0 or (b < 0 and c > 0):
	print(min(abs(a), abs(b)) * min(abs(c), abs(d)) * -1)
else:
	print(max(a * c, a * d, b * c, b * d))


(a, b, c, d) = map(int, input().split(' '))
print(max(a * c, a * d, b * c, b * d))


(A, B, C, D) = map(int, input().split())
print(max(A * C, A * D, B * C, B * D))


(a, b, c, d) = [int(x) for x in input().split()]
print(max([a * c, a * d, b * c, b * d]))


l = list(map(int, open(0).read().split()))
ans = [l[0] * l[2], l[0] * l[3], l[1] * l[2], l[1] * l[3]]
print(max(ans))


import math
(a, b, c, d) = map(int, input().split())
print(max(a * c, a * d, b * c, b * d))


(a, b, c, d) = map(int, input().split())
res = -float('inf')
for x in [a, b]:
	for y in [c, d]:
		res = max(x * y, res)
print(res)


(a, b, c, d) = [int(s) for s in input().split()]
ls = [a * c, a * d, b * c, b * d]
print(max(ls))


(a, b, c, d) = (int(T) for T in input().split())
print(max(a * c, a * d, b * c, b * d))


(a, b, c, d) = list(map(int, input().split()))
l = [a * d, a * c, b * c, b * d]
print(max(l))


In = map(str, input().split())
In_list = list(In)
for i in range(len(In_list)):
	In_list[i] = int(In_list[i])
ac = In_list[0] * In_list[2]
ad = In_list[0] * In_list[3]
bc = In_list[1] * In_list[2]
bd = In_list[1] * In_list[3]
ans_list = [ac, ad, bc, bd]
ans_list.sort()
print(ans_list[3])


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
(a, b, c, d) = rm()
print(max([b * c, a * c, a * d, b * d]))


import sys
(a, b, c, d) = sys.stdin.readline().strip().split(' ')
a = int(a)
b = int(b)
c = int(c)
d = int(d)
res_max = max(a * c, a * d, b * c, b * d)
print(res_max)


l = list(map(int, input().split()))
(x_l, y_l) = (l[0:2], l[2:4])
max_result = float('-inf')
for x in x_l:
	for y in y_l:
		result = x * y
		if max_result < result:
			max_result = result
print(max_result)


(x, y, z, w) = map(int, input().split())
l = []
l.append(x * z)
l.append(x * w)
l.append(y * z)
l.append(y * w)
print(max(l))


(a, b, c, d) = map(int, input().split())
Ans1 = a * c
Ans2 = a * d
Ans3 = b * c
Ans4 = b * d
nums = [Ans1, Ans2, Ans3, Ans4]
print(max(nums))


(a, b, c, d) = map(int, input().split())
ans = 0
ans = max(a * c, a * d, b * c, b * d)
print(ans)


def cin():
	return list(map(int, input().split()))
num = cin()
a = num[0]
b = num[1]
c = num[2]
d = num[3]
temp = []
temp.append(a * c)
temp.append(a * d)
temp.append(b * c)
temp.append(b * d)
print(max(temp))


resultnum = []
inputnum = input().split()
for tmp in range(2):
	resultnum.append(int(inputnum[tmp]) * int(inputnum[2]))
	resultnum.append(int(inputnum[tmp]) * int(inputnum[3]))
print(str(max(resultnum)))


from sys import stdin
(a, b, c, d) = [int(_) for _ in stdin.readline().rstrip().split()]
print(max([a * c, a * d, b * c, b * d]))


import math
num_list = list(map(int, input().split()))
a = num_list[0]
b = num_list[1]
c = num_list[2]
d = num_list[3]
result = max(max(a * c, a * d), max(b * c, b * d))
print(result)


(a, b, c, d) = (int(i) for i in input().split())
print(max(a * c, b * d, a * d, b * c))


(a, b, c, d) = [int(r) for r in input().split()]
print(max(a * c, a * d, b * c, b * d))


(a, b, c, d) = map(int, input().split())
ans = a * c
if ans < a * d:
	ans = a * d
if ans < b * c:
	ans = b * c
if ans < b * d:
	ans = b * d
print(ans)


(a, b, c, d) = map(int, input().split())
e = max(a * c, a * d)
f = max(b * c, b * d)
print(max(e, f))


(a, b, c, d) = map(int, input().split())
if a >= 0 and b >= 0:
	if d >= 0:
		print(b * d)
	else:
		print(a * d)
elif a < 0 and b >= 0:
	if c >= 0 and d >= 0:
		print(b * d)
	elif c < 0 and d >= 0:
		if abs(a) * abs(c) >= b * d:
			print(abs(a) * abs(c))
		else:
			print(b * d)
	elif c < 0 and d < 0:
		print(a * c)
elif a < 0 and b < 0:
	if c >= 0 and d >= 0:
		print(b * c)
	elif c < 0:
		print(a * c)


(a, b, c, d) = map(int, input().split())
ans = []
ans.append(a * c)
ans.append(a * d)
ans.append(b * c)
ans.append(b * d)
print(max(ans))


(a, b, c, d) = map(int, input().split())
p = a * c
q = a * d
r = b * c
s = b * d
print(max(p, q, r, s))


(a, b, c, d) = map(int, input().split())
ans_list = [a * c, a * d, b * c, b * d]
ans_list.sort()
ans = ans_list.pop()
print(ans)


(a, b, c, d) = map(int, input().split())
result_1 = []
result_2 = []
if a <= b and c <= d:
	x = [a, b]
	y = [c, d]
	r1 = x[0] * y[0]
	r2 = x[0] * y[1]
	result_1.append(r1)
	result_1.append(r2)
	r3 = x[1] * y[0]
	r4 = x[1] * y[1]
	result_2.append(r3)
	result_2.append(r4)
	x = max(result_1)
	y = max(result_2)
	result = max(x, y)
print(result)


a = (*map(int, input().split()),)
print(max((x * y for x in a[:2] for y in a[2:])))


(a, b, c, d) = map(int, input().split(' '))
l = []
l.append(a * c)
l.append(a * d)
l.append(b * c)
l.append(b * d)
print(max(l))


(a, b, c, d) = map(int, input().split())
f = 1
g = 1
ans = 1
print(max(a * c, a * d, b * c, b * d))


(A, B, C, D) = list(map(int, input().split()))
print(max(max(A, B) * max(C, D), min(A, B) * max(C, D), max(A, B) * min(C, D), min(A, B) * min(C, D)))


import numpy as np
(a, b, c, d) = map(int, input().split())
x = np.array([a, b])
y = np.array([c, d])
m = np.outer(x, y)
ret = np.max(m)
print(ret)


a = [int(x) for x in input().split()]
print(max([a[0] * a[2], a[0] * a[3], a[1] * a[2], a[1] * a[3]]))


(a, b, c, d) = list(map(int, input().split()))
s = a * c
t = a * d
u = b * c
v = b * d
print(max(s, t, u, v))


(a, b, c, d) = map(int, input().split())
r1 = a * c
r2 = b * d
r3 = a * d
r4 = b * c
print(max(r1, r2, r3, r4))


(a, b, c, d) = map(int, input().split())
x = a * c
y = a * d
z = b * c
w = b * d
n = max(x, y, z, w)
print(n)


(a, b, c, d) = list(map(int, input().split()))
ll = [a * c, a * d, b * c, b * d]
print(max(ll))


(a, b, c, d) = list(map(int, input().split()))
charo = [a * c, a * d, b * c, b * d]
print(max(charo))


(a, b, c, d) = map(int, input().split())
u = max(a * c, a * d)
v = max(b * c, b * d)
print(max(u, v))


(a, b, c, d) = list(map(int, input().split()))
calc = [a * c, a * d, b * c, b * d]
print(max(calc))


(a, b, c, d) = list(map(int, input().split()))
res = [a * c, a * d, b * c, b * d]
print(max(res))


(a, b, c, d) = list(map(int, input().split()))
Max_ac = a * c
Max_ad = a * d
Max_bc = b * c
Max_bd = b * d
Max_list = [Max_ac, Max_ad, Max_bc, Max_bd]
print(max(Max_list))


(a, b, c, d) = input().split()
x = [int(a), int(b)]
y = [int(c), int(d)]
nums = []
for i in range(len(x)):
	for j in range(len(y)):
		num = x[i] * y[j]
		nums.append(num)
max_num = max(nums)
print(max_num)


(a, b, c, d) = map(int, input().split())
x1 = a * c
x2 = a * d
x3 = b * c
x4 = b * d
ans = max(x1, x2, x3, x4)
print(ans)


(a, b, c, d) = map(int, input().split())
x = max(a * c, b * d)
y = max(a * d, b * c)
print(max(x, y))


(a, b, c, d) = list(map(int, input().split()))
ans = max(a * c, a * d, b * c, b * d)
print(ans)


(a, b, c, d) = map(int, open(0).read().split())
print(max(a * c, a * d, b * c, b * d))


(a, b, c, d) = map(int, input().split())
ac = a * c
ad = a * d
bc = b * c
bd = b * d
print(max([ac, ad, bc, bd]))


(a, b, c, d) = map(int, input().split())
A = a * c
B = a * d
C = b * c
D = b * d
N = [A, B, C, D]
print(max(N))


(a, b, c, d) = list(map(int, input().split()))
li = [a * c, b * c, a * d, b * d]
print(max(li))


[a, b, c, d] = [int(_) for _ in input().split()]
print(max([a * c, a * d, b * c, b * d]))


(a, b, c, d) = (int(x) for x in input().split())
ac = a * c
ad = a * d
bc = b * c
bd = b * d
q = [ac, ad, bc, bd]
high = q[0]
for value in q:
	if value > high:
		high = value
print(high)


(a, b, c, d) = list(map(int, input().split()))
x = max(a * d, a * c, b * d, b * c)
print(x)


(a, b, c, d) = list(map(int, input().split()))
hoge = [a * c, a * d, b * c, b * d]
print(max(hoge))


(a, b, c, d) = map(int, input().split())
l = [a * c, a * d, b * c, b * d]
Ans = max(l)
print(Ans)


(a, b, c, d) = map(int, input().split())
product_list = [a * c, a * d, b * c, b * d]
ans = max(product_list)
print(ans)


(a, b, c, d) = list(map(int, input().split()))
R = []
R = [a * c, a * d, b * c, b * d]
print(max(R))


(a, b, c, d) = [int(n) for n in input().split()]
print(max(a * c, b * c, a * d, b * d))


temp = input().split(' ')
num_list = [int(s) for s in temp]
ans_list = []
for i in range(2):
	for j in range(2, 4, 1):
		ans = num_list[i] * num_list[j]
		ans_list.append(ans)
print(max(ans_list))


import sys
(a, b, c, d) = map(int, input().split())
if a < 0 and b < 0:
	if c < 0:
		print(a * c)
		return
	else:
		print(b * c)
		return
if a < 0 and b >= 0:
	if c < 0 and d < 0:
		print(a * c)
	elif c < 0 and d >= 0:
		print(max(a * c, b * d))
	else:
		print(b * d)
	return
if c < 0 and d < 0:
	print(a * d)
else:
	print(b * d)
return


(a, b, c, d) = [int(v) for v in input().split()]
print(max([a * c, a * d, b * c, b * d]))


(a, b, c, d) = list(map(int, input().split()))
tmp = [a * c, a * d, b * c, b * d]
print(max(tmp))


(a, b, c, d) = list(map(int, input().split()))
e = [a * c, a * d, b * c, b * d]
print(max(e))


N = list(map(int, input().split()))
A = N[0]
B = N[1]
C = N[2]
D = N[3]
print(max(A * C, A * D, B * C, B * D))


from itertools import product

def answer(a: int, b: int, c: int, d: int) -> int:
	return max((x * y for (x, y) in product((a, b), (c, d))))

def main():
	(a, b, c, d) = map(int, input().split())
	print(answer(a, b, c, d))

def __starting_point():
	main()
__starting_point()


(a, b, c, d) = map(int, input().split())
k = [0] * 4
k[0] = a * c
k[1] = a * d
k[2] = b * c
k[3] = b * d
m = sorted(k)
print(m[3])


(a, b, c, d) = list(map(int, input().split()))
ans_ = [a * c, b * c, a * d, b * d]
print(max(ans_))


(a, b, c, d) = list(map(lambda x: int(x), input().split()))
ac = a * c
ad = a * d
bc = b * c
bd = b * d
ans = max([ac, ad, bc, bd])
print(ans)


(a, b, c, d) = [int(_n) for _n in input().split()]
print(max([a * c, a * d, b * c, b * d]))


def product_max(a, b, c, d):
	print(max(a * c, a * d, b * c, b * d))

def __starting_point():
	(a, b, c, d) = map(int, input().split())
	product_max(a, b, c, d)
__starting_point()


(a, b, c, d) = [int(t) for t in input().split()]
print(max([b * d, a * c, a * d, b * c]))


(a, b, c, d) = list(map(int, input().split()))
all_prod = []
for x in [a, b]:
	for y in [c, d]:
		all_prod.append(x * y)
print(max(all_prod))


(a, b, c, d) = [int(s) for s in input().split()]
prods = [a * c, a * d, b * c, b * d]
m = max(prods)
print(m)


(a, b, c, d) = map(int, input().split())
ans = [a * c, a * d, b * c, b * d]
x = max(ans)
print(x)