LAST SUBSET PROBLEM

Given an array of integers A of size N.

Value of a subset of array A is defined as product of all prime numbers in that subset.
If there is no prime number in a subset value of such a subset is 1.

Calculate and return product of values of all possible non-empty subsets of array A % (10^9 + 7).



Input Format

The first and only argument given is the integer array A.

Output Format

Calculate and return product of values of all possible non-empty subsets of array A% (10^9 + 7).

Constraints

1 <= N <= 10^5
1 <= A[i] < 10^5

For Example

Input 1:
    A = [3, 7]
Output 1:
    441
Explaination 1:
    Value ( [3] ) = 3
    value ( [7] ) = 7
    value ( [3, 7] ) = 21
    answer = (3 * 7 * 21) % 1000000007 = 441

Input 2:
    A = [4]
Output 2:
    1
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving LAST SUBSET PROBLEM on Interview Code Editor
Sign Up
to access hints and editorial solutions for LAST SUBSET PROBLEM

Discussion


Loading...
Click here to start solving coding interview questions