solutions for POJ problems