Help for this Problem-LightOJ

I am stuck with this problem, can somebody help me to solve this problem?