Help with Launch Tower (ACM14AM3)

I was trying to solve the Launch Tower problem (ACM14AM3 Problem - CodeChef). After trying very hard to come up with a solution I decided to look at the editorial (ACM14AM3-Editorial) but I could not understand anything, it felt ambiguous to me. Can anyone help me by explaining the dynamic-programming approach for the problem?
Really, the main observation is that to append a digit to a number, we multiply it by 10 and add the digit, which is also true modulo some number n.

1 Like