POJ homework