Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Count Ways to Make Array With Product

XPChallenge Points: 30
levelLevel: Hard

You are given a list of queries.
Each query is a pair [n, k], meaning:


• n = the length of the array to create
• k = the product that all numbers in the array must multiply to
Find how many different arrays of length n (containing only positive integers) have a product exactly equal to k.
Because the result can be very large, return the answer for each query modulo 10⁹ + 7.


Example 1:

Input: queries = [[2,6],[5,1],[73,660]]

Output: [4,1,50734910]

Explanation:

• [2,6]: 4 arrays multiply to 6 → [1,6], [6,1], [2,3], [3,2]. • [5,1]: Only 1 array works → [1,1,1,1,1]. • [73,660]: There are 1,050,734,917 valid arrays. After taking modulo 1,000,000,007, the answer is 50,734,910.

Example 2:

Input: queries = [[1,1],[2,2],[3,3],[4,4],[5,5]]

Output: [1,2,3,10,5]

Explanation:

• [1,1] → 1 way: [1] • [2,2] → 2 ways: [1,2], [2,1] • [3,3] → 3 ways • [4,4] → 10 ways • [5,5] → 5 ways

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result