9671680 | CodeChef

Can someone please explain me step by step that how to solve this problem cause am I not able to understand from youtube video explaination