问题:
找出是否可以用21,19和37构成一个整数(例如N)?
a. N will be provided as input
b. You can use only these three numbers: 27,19,37
c. Only multiplication, addition, repetition and replacement are allowed例如:
Input: 24, Output: not possible
Input: 94, Output: possible - 94 = 19*3 + 37我的问题是:
发布于 2013-11-18 06:00:09
它与背包问题相同,参数如下:
W = Knapsack capacity = N
items = 19 ( N/19 times), 27 (N/27 times), 37 (N/37 times).
Cost & weight of items are same.
Maximize profit. If maximum profit equals N then it is possible to construct N using 19,27,37背包问题有一个DP解:-
背包问题
注意:,您应该自己研究背包问题,不要为其代码发布另一个问题。
https://stackoverflow.com/questions/20035605
复制相似问题