dp(i, maxSoFar, remain)
.i == n
, return 1
if remain == 0
, and 0
otherwise.remain < 0
, return 0
.ans
as maxSoFar * dp(i + 1, maxSoFar, remain)
.num
in the range [maxSoFar + 1, m]
:
dp(i + 1, num, remain - 1)
to ans
.ans
.dp(0, 0, k)
as the answer to the original problem.