Help needed in SUBNUM practice question

https://www.codechef.com/viewsolution/25355736