'Coding has over 700 languages', '67% of programming jobs aren’t in the technology industry', 'Coding is behind almost everything that is powered by electricity'
Topics

# Count Ways To Make Array With Product

Moderate
0/80
Average time to solve is 30m
Contributed by

## Problem statement

There are two friends Ranbir and Alia. Ranbir gave a question to Alia that you are given ‘Q’ queries in the form [N, P].

For each query, Alia has to count how many arrays consisting of positive integers of size ‘N’ she could build such that the product of all the array elements is equal to ‘P’.

Since the answer could be large, return the answer to each query modulo 10^9 + 7.

Detailed explanation ( Input/output format, Notes, Images )
Constraints :
``````1 <= T <= 10
1 <= Q <= 10^4
1 <= N , P <= 10^4

Time Limit: 1 sec
``````
Sample Input 1 :
``````2
2
2 6
1 1
1
5 1
``````
Sample Output 1 :
``````4 1
1
``````
Explanation For Sample Input 1 :
``````For the first test case, consider each query independently

For the first query where we have to build an array of size 2 and the product of array, elements should be equal to 6. So all the possible arrays are: {1, 6}, {6, 1}, {2, 3} and {3, 2}. Therefore, the answer will be 4 for the given query.

For the second query where we have to build an array of size 1 and the product of the array, elements should be equal to 1. So the only possible array is {1}. Therefore, the answer will be 1 for the given query.

For the second test case, consider each query independently

For the first query where we have to build an array of size 5 and the product of array elements should be equal to 1. So the only possible array is {1, 1, 1, 1, 1}. Therefore, the answer will be 1 for the given query.
``````
Sample Input 2 :
``````2
2
7 20
2 2
2
3 6
3 4
``````
Sample Output 2 :
``````196 2
9 6
``````
Console