Minimum element whose N-th power is greater than product of an array
Submissions: 1386   Accuracy:

10.14%

  Difficulty: Easy   Marks: 2

Given an array of N numbers. the task is to find minimum positive integer which can be assigned to every array element such that product of all elements of this new array is strictly greater than product of all elements of the initial array.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting size of array and the second line contains N space separated array elements.

Output:
For each test case, print the minimum required element in new line.

Constraints:
1<=T<=200
1<=N<=106
1<=A[i]<=106

Example:
Input:

2
5
4 2 1 10 6
4
3 2 1 4

Output:
4
3

Explanation:

Input: 3 2 1 4 
Output: 3
Product of elements of initial
array 3*2*1*4 = 24. If x = 3 then 3*3*3*3 
= 81, if x = 2 then 2*2*2*2 =16. So minimal
element = 3.

** For More Input/Output Examples Use 'Expected Output' option **

Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.