Count Ways to Make Array With Product - Problem
You are given a 2D integer array queries. For each queries[i], where queries[i] = [ni, ki], find the number of different ways you can place positive integers into an array of size ni such that the product of the integers is ki.
As the number of ways may be too large, the answer to the ith query is the number of ways modulo 109 + 7.
Return an integer array answer where answer.length == queries.length, and answer[i] is the answer to the ith query.
Input & Output
Example 1 — Basic Query
$
Input:
queries = [[2,6],[3,1]]
›
Output:
[4,1]
💡 Note:
For [2,6]: arrays [1,6], [2,3], [3,2], [6,1] all have product 6, so 4 ways. For [3,1]: only [1,1,1] has product 1, so 1 way.
Example 2 — Single Element
$
Input:
queries = [[1,10]]
›
Output:
[1]
💡 Note:
Array of size 1 with product 10: only [10] works, so 1 way.
Example 3 — Larger Array
$
Input:
queries = [[4,2]]
›
Output:
[4]
💡 Note:
Arrays of size 4 with product 2: [2,1,1,1], [1,2,1,1], [1,1,2,1], [1,1,1,2], so 4 ways.
Constraints
- 1 ≤ queries.length ≤ 104
- 1 ≤ ni ≤ 104
- 1 ≤ ki ≤ 104
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code