In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of C language dynamic planning how to solve a variety of knapsack problems, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe that after reading this article on how to solve a variety of knapsack problems in C language dynamic planning, we will gain something. Let's take a look.
01 knapsack problem
Detailed explanation of C language Mathematical problem and simple DP01 knapsack problem
Recall this picture first.
Here I will send the 01 knapsack problem code again, which can be used for comparison.
2D:
# includeusing namespace std;const int MAXN = 1005 int int v [MAXN]; / / Volume int w [MAXN]; / / value int f [MAXN] [MAXN]; / / f [I] [j], maximum value of the first I items under j volume int main () {int n, m; cin > n > m; for (int I = 1; I > v [I] > > w [I]; for (int I = 1; I m For (int I = 1; I > v > > w; / input while processing for (int j = m; j > = v; JML -) f [j] = max (f [j], f [j-v] + w);} cout n > > m; for (int I = 1; I > v [I] > w [I]; for (int I = 1; i m; ll aline bc) For (ll iTunes 1 [I] > a > b > > c; for (ll js [I]); for (int juniors j > v [I] [j] > > w [I] [j]); / / read} for (int iridges 1 [iv] [j] > > w [I] [j];}} for (int itimulties 0 / 10 / 0 / 10) {for (int / I / 0 / 1) KMQ -) can also if (j > = v [I] [k]) f [j] = max (f [j], f [JQ v [I] [k]] + w [I] [k]);}} cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.