How to use C++ dynamic programming algorithm
Most people do not understand the knowledge points of this article "how to use the C++ dynamic planning algorithm", so the editor summarizes the following contents for you, with detailed contents and clear steps, which can be used for reference. I hope you can get something after reading this article, let's take a look at this "C++ dynamic planning algorithm how to use" article.
Fibonacci
Topic description:
As we all know, the Fibonacci series is now required to enter a positive integer n. Please output the nth term of the Fibonacci series.
Ideas for solving the problem:
1. Recursion
two。 Dynamic programming
Status: F (n)
State recursion: F (n) = F (nmur1) + F (nmur2)
Initial value: F (1) = F (2) = 1
Returned result: F (N)
Code implementation:
Method 1: recursion (low efficiency):
Class Solution {public: int Fibonacci (int n) {/ / initial value if (n