Http://lightoj.com/volume_showproblem.php?problem=1005

http://lightoj.com/volume_showproblem.php?problem=1005

can anyone help me with the above question. I saw various answers but unable to understand the concept behind them.

Can u send screenshot?it needs login to read problem

http://lightoj.com/volume_showproblem.php?problem=1005&language=english&type=pdf