atcoder#ABC173E. [ABC173E] Multiplication 4
[ABC173E] Multiplication 4
Score : points
Problem Statement
Given are integers .
We will choose exactly of these elements. Find the maximum possible product of the chosen elements.
Then, print the maximum product modulo , using an integer between and (inclusive).
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the maximum product modulo , using an integer between and (inclusive).
4 2
1 2 -3 -4
12
The possible products of the two chosen elements are , , , , , and , so the maximum product is .
4 3
-1 -2 -3 -4
1000000001
The possible products of the three chosen elements are , , , and , so the maximum product is .
We print this value modulo , that is, .
2 1
-1 1000000000
1000000000
The possible products of the one chosen element are and , so the maximum product is .
10 10
1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1
999983200
Be sure to print the product modulo .