#P8669. [蓝桥杯 2018 省 B] 乘积最大
[蓝桥杯 2018 省 B] 乘积最大
Problem Description
Given integers . Please choose numbers from them so that their product is maximized.
Output the maximum product. Since the product may exceed the integer range, you only need to output the remainder of the product modulo (i.e., ).
Note that if , we define the remainder of divided by as .
Input Format
The first line contains two integers and .
In the next lines, each line contains one integer .
Output Format
Output one integer, the answer.
5 3
-100000
-10000
2
100000
10000
999100009
5 3
-100000
-100000
-2
-100000
-100000
-999999829
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5