Can anyone tell me how I can proceed to solve this problem https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4108 . ( I am unable to find any good content which explains the solution of this problem. ) Thank You. Updated Link of the problem:https://uva.onlinejudge.org/external/13/1362.pdf