Dynamic Programming

发布时间 2023-06-14 10:49:13作者: zwyyy456

Description

Usually, One-dimensional dynamic planning problem, the parameter is always $n$, the result is similar to number sequence $a_n$, or $f(n)$($f$ can be viewed as function or corresponding relationship). At the same time, there will be certain corresponding relationship between $a_n$ and $a_{n - 1}, a_{n - 2}...a_{1}$, such as $a_n = a_{n-1} + a_{n-2}$(fibonacci sequence).

Solution

Number sequence can be corresponded with array in programming language such as C++. If you find the recursive relationship among number sequence, you can write traversal code using for loop to get the answer.

Examples