Unable to get the logic in DECSTR

Problem link: DECSTR Problem - CodeChef

Hello Friends. I am unable to get any logic for the above question. Please can somebody explain me the logic?? Please help.