Prepare solve by DP
solve by DP