#P8669. [蓝桥杯 2018 省 B] 乘积最大

    ID: 9865 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>贪心2018蓝桥杯省赛分类讨论

[蓝桥杯 2018 省 B] 乘积最大

Problem Description

Given NN integers A1,A2,,ANA_1, A_2,\cdots, A_N. Please choose KK 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 10000000091000000009 (i.e., 109+910^9+9).

Note that if X<0X<0, we define the remainder of XX divided by 10000000091000000009 as 0((0x)mod1000000009)0-((0-x)\bmod 1000000009).

Input Format

The first line contains two integers NN and KK.

In the next NN lines, each line contains one integer AiA_i.

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 40%40\% of the testdata, 1KN1001\le K\le N\le 100.

For 60%60\% of the testdata, 1K10001\le K \le 1000.

For 100%100\% of the testdata, 1KN1051\le K\le N\le 10^5, 105Ai105-10^5\le A_i\le 10^5.

Translated by ChatGPT 5