Minimum Product of k Integers
Basic Accuracy: 25.69% Submissions: 9338 Points: 1

Given an array of N positive integers. You need to write a program to print the minimum product of k integers of the given array.

Examples:

Input : 198 76 544 123 154 675
         k = 2
Output : 9348
We get minimum product after multiplying
76 and 123.

Input : 11 8 5 7 5 100
        k = 4
Output : 1400

Note: Since output could be large, hence module 10^9+7 and then print answer.

Input:
First line of the input contains an integer T, denoting the number of test cases. Then T test case follows. First line of each test case contains an integer N, denoting the size of the array. Next line contains N space separated integers denoting the elements of the array. Last line of each test case contains the integer K.

Output:
For each test case print the required anwer in a new line.

Constraints:
1<=T<=103
1<=K<=N<=105

Example:
Input:

2
5
1 2 3 4 5
2
3
9 10 8
3
Output:
2
720

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.