To Good Arrays
Learn this problemProblem statement
You are given three integers N, M and K.
An array is said to be good if there is exactly K indices i such that A[i] * A[i + 1] is equal to M.
Find the number of good arrays A. Since the answer can be very large, return it modulo 10^9 + 7.
Input Format
The first line contains an integer, N, denoting one of the given three integers.
The next line contains an integer, M, denoting one of the three given integers.
The next line contains an integer, K, denoting one of the three given integers.
Function
countGoodArrays(N: int, M: int, K: int) → intExamples
Example 1
N = 2M = 3K = 0return = 7
Given N = 2, M = 3, K = 0.
There exists 7 possible arrays A. Some of them are [3, 3] and [1, 2].
Example 2
N = 2M = 3K = 1return = 2
Given N = 2, M = 3, K = 1.
There exists only two possible arrays A which are [1, 3] and [3, 1].
Example 3
N = 5M = 10K = 2return = 1368
Given N = 5, M = 10, K = 2.
There exists a total of 1368 possible arrays A.
Constraints
2 <= N <= 10^93 <= M <= 10^90 <= K <= min(50, N - 1)
More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026