problem solution of poj.org