哇~~~不是吧 经典DP啊~~ subset sum.... The array can now be filled in using a simple recursion. Initially, for N ≤ s ≤ P, set Q(1,s) := (x1 = s). Then, for i = 2, …, n, set Q(i,s) := Q(i − 1,s) or (xi = s) or Q(i − 1,s − xi) for N ≤ s ≤ P.
【在 g***s 的大作中提到】 : 连续的才是。这题不是。 : : 】
e*e
10 楼
这和连不连续没有任何关系~~~
【在 g***s 的大作中提到】 : 连续的才是。这题不是。 : : 】
g*s
11 楼
"In computer science, the subset sum problem is an important problem in complexity theory and cryptography. The problem is this: given a set of integers, does the sum of some non-empty subset equal exactly zero? For example, given the set { −7, −3, −2, 5, 8}, the answer is yes because the subset { −3, −2, 5} sums to zero. The problem is NP-complete. An equivalent problem is this: given a set of integers and an integer s, does any non-empty subset sum to s? Subset sum can also be thought of as a special case of the knapsack problem. One interesting special case of subset sum is the partition problem, in which s is half of the sum of all elements in the set." In the question, it doesn't mention 1) they are integer 2) there are range for the numbers You solution is just for a special case.
【在 e*****e 的大作中提到】 : 这和连不连续没有任何关系~~~
F*r
12 楼
能说说具体怎么实现或者怎么reconstruct soluton么?
【在 e*****e 的大作中提到】 : 哇~~~不是吧 : 经典DP啊~~ : subset sum.... : The array can now be filled in using a simple recursion. Initially, for N ≤ : s ≤ P, set : Q(1,s) := (x1 = s). : Then, for i = 2, …, n, set : Q(i,s) := Q(i − 1,s) or (xi = s) or Q(i − 1,s − xi) : for N ≤ s ≤ P.
s*y
13 楼
re
【在 e*****e 的大作中提到】 : 这和连不连续没有任何关系~~~
i*d
14 楼
N ≤
你这个应该算backtracking。
【在 e*****e 的大作中提到】 : 哇~~~不是吧 : 经典DP啊~~ : subset sum.... : The array can now be filled in using a simple recursion. Initially, for N ≤ : s ≤ P, set : Q(1,s) := (x1 = s). : Then, for i = 2, …, n, set : Q(i,s) := Q(i − 1,s) or (xi = s) or Q(i − 1,s − xi) : for N ≤ s ≤ P.