POJ 1050 : To the Max solved