Count Ways to Make Array With Product

You are given a 2D integer array, queries. For each queries[i], where queries[i] = [n_i, k_i], find the number of different ways you can place positive integers into an array of size n_i such that the product of the integers is k_i. As the number of ways may be too large, the answer to the i^th query is the number of ways modulo 10^9 + 7.

Return an integer array answer where answer.length == queries.length, and answer[i] is the answer to the i^th query.

Example 1
Inputqueries = [[2,6],[5,1],[73,660]]
Output[4,1,50734910]
Each query is independent: the first has 4 valid arrays, the second has 1 valid array, and the third has 1050734917 ways, which is 50734910 modulo 10^9 + 7.
Example 2
Inputqueries = [[1,1],[2,2],[3,3],[4,4],[5,5]]
Output[1,2,3,10,5]
For the five independent queries, the numbers of arrays with the required sizes and products are 1, 2, 3, 10, and 5 respectively.

Constraints

  • 1 <= queries.length <= 10^4
  • 1 <= ni, ki <= 10^4

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate