POJ3709 with DP