I need help with a problem like this: Count the number of arrays of n elements in which each element of the array has the value of paragraph [1, M] so that there are the same K consecutive values. with n, M, K <= 1000000 For example: n = 3, M = 2, k = 2 The result will be 6 satisfying fields that are (1,1,1); (1,1,2); (1,2,2); (2,1,1); (2,2,1); (2,2,2)