Help in digit dp problem

Can someone help in this problem CodeChef: Practical coding for everyone. Editorial is not clear.