Link - https://hack.codingblocks.com/contests/c/547/846

How to solve this problem??
https://hack.codingblocks.com/contests/c/547/846