Question Link:Click here ~
Question Analysis:
Give a wooden rod with a length of L and give n places to be cut. You need to complete the task at the minimum cost. How is the cost calculated? That is, the length of the current wooden rod is used.
Algorithm analysis:
The memory process can reduce a lot of time. The essence of this question is the interval DP. The original question is the typical issue of stone merge. If it is hard to understand, you can think about the flody model in graph theory.
State transition equation: DP [I] [J] = min (DP [I] [J], solve (I, K) + solve (K, J) + Len [J]-len [I]) is essentially a flody model conversion.
When applied to the memory-based search, there are generally two termination conditions. One is available according to the requirements of the question, and the other is to avoid repeated computation and directly use the previous results.
First, if (I + 1 = J) return 0; that is, only one merging interval exists.