ACM summary seven

These days learning a little knapsack problem, summarize here backpack major problem three categories:
01 knapsack problem
which is the most basic knapsack problem, characterized by: each item is only one, there are two states or leave .
Subproblem defined by the state: i.e., F [i] [v] denotes the front i items placed exactly a maximum capacity value v backpack available. It is the state transition equation:
F [i] [V] = max {F [. 1-i] [V], F [i-. 1] [VC [i]] + W [i]}
considering only the i strategy of items (or leave)

Complete knapsack problem
for each item infinite pieces
associated with its policy was not to take or not take two types, but have to take 0, take one, take two ...... and so are many.
So that F [i] [v] denotes the i article just before into a maximum weight capacity of the backpack v. Still state transition equation can be written for each item in a different strategy, such as:
F [I] [V] = max {F [. 1-I] [VK C [I]] + K W [I] | 0 < = k * c [i] < = v}

Multiple knapsack problem
subject
has N kinds of goods and a backpack capacity of V. N-i th most items [i] member is available, the cost of each is C [i], is the value of w [i]. Solving the items into a backpack which allows the total cost of these items does not exceed the capacity of the backpack, and the sum of the maximum value.
Because there are n [i] +1 for i-th species policy items: take 0, take n-1 ...... take [i] member. So that F [i] [v] denotes the i article just before into a maximum weight capacity of v backpack, there is the state transition equation:
F [i] [v] = max {F [. 1-i] [ VK C [I]] + K W [I] | 0 <= K <= n-[I]}

Guess you like

Origin blog.csdn.net/qq_43515378/article/details/89007276