Imagine you're a mathematician tasked with finding all possible ways to arrange positive integers in an array such that their product equals a specific target value.
You are given a 2D integer array queries, where each queries[i] = [ni, ki] represents a challenge:
- ni: The size of the array you need to create
- ki: The target product that all elements must multiply to
For each query, you need to count how many different ways you can place positive integers into an array of size ni such that the product of all integers equals ki.
Example: If n=2 and k=6, valid arrays include [1,6], [2,3], [3,2], [6,1] - that's 4 different ways!
Since the answer can be extremely large, return each result modulo 109 + 7.
Input & Output
Visualization
Time & Space Complexity
Sieve for preprocessing + Q queries × number of distinct prime factors
Space for storing prime factorizations and precomputed factorials
Constraints
- 1 ≤ queries.length ≤ 104
- 1 ≤ ni, ki ≤ 104
- All positive integers must be ≥ 1
- Answer should be returned modulo 109 + 7