https://www.codechef.com/HCS12019/problems/SETH0002

https://www.codechef.com/HCS12019/problems/SETH0002

Please explain the logic one should use.