Count Sequences With Product X Problem Statement
You are provided with an array NUM
containing N
positive integers. Your objective is to find the total number of possible sequences of positive integers (greater than 1) whose product equals X
.
Explanation:
The value of X
is computed as the product of N
terms, where each ith
term is represented by the ith
prime number raised to the power of the ith
element in the given array.
In mathematical terms, X
can be expressed as:
X = 2 ^ NUM[1] * 3 ^ NUM[2] * 5 ^ NUM[3] * 7 ^ NUM[4] * 11 ^ NUM[5] * … up to Nth term
Input:
The first line of input contains an integerT
, representing the number of test cases.
Then,T
test cases follow.
Each test case begins with a line containing a single integerN
, the size of the arrayNUM
.
The subsequent line containsN
space-separated integers, the elements ofNUM
.
Output:
For each test case, output a single integer on a new line representing the total number of possible sequences of positive integers (greater than 1) whose product equals X
.
Example:
Input:
2
3
1 2 1
2
1 1
Output:
6
3
Constraints:
- The sum of all elements in array
NUM
will always be ≤ 400. - The answer should be printed modulo
1000000007
, due to potentially large sizes. 1 ≤ T ≤ 10
2 ≤ N ≤ 500
1 ≤ NUM[i] < 100
- Time Limit: 1 second
Note:
You are not required to print anything explicitly. Simply implement the desired function, and it will handle the output.

AnswerBot
4mo
Count the total number of possible sequences of positive integers whose product equals X.
Calculate the product X using the given formula
Find all the divisors of X
Count the number of sequences with pro...read more
Help your peers!
Add answer anonymously...
TCS iON Software Developer interview questions & answers
A Software Developer was asked 3mo agoQ. What are loops in Python?
A Software Developer was asked 3mo agoQ. What is the process to find a substring within an array?
A Software Developer was asked 8mo agoQ. How do you reverse a sorted array?
Popular interview questions of Software Developer
A Software Developer was asked 3mo agoQ1. What are loops in Python?
A Software Developer was asked 3mo agoQ2. What is the process to find a substring within an array?
A Software Developer was asked 6mo agoQ3. Why should we hire you?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

