3405. Count the Number of Arrays with K Matching Adjacent Elements
You are given three integers
n
,m
,k
. A good arrayarr
of sizen
is defined as follows:
- Each element in
arr
is in the inclusive range[1, m]
.- Exactly
k
indicesi
(where1 <= i < n
) satisfy the conditionarr[i - 1] == arr[i]
.Return the number of good arrays that can be formed.
Since the answer may be very large, return it modulo
109 + 7
.
c++
1 |
|