And so you could construct all subsets, check that the weight is less than the weight of the knapsack, and then choose the subset with the maximum value.
因此你可以构建所有子问题,判断它的重量,是否小于背包的重量,然后选择值最大的子问题。
If there are less than two elements there I just check one or both of those to see if I'm looking for the right thing.
列表里是否剩余超过两个元素?,是否剩余不足两个元素,这里面我就挑一两项来检查下是否运行正常。
At this point in the story, I now check while n is less than 1, what do I do?
在此时此刻,我现在在检查当n小于1是,我做什么?
All right, it's so if I looked at it, sorry, IF x is less than y, THEN check to see IF x is less than z, and if that's true, print out x is the smallest.
好,代码是这样的,对不起,是不是x比y小,然后去看看是不是x比z小,如果都为真的话,显示x为最小值。
I test an end test. So the flow chart says, and the tradition was to do this in a diamond shape, I'm going to check if ANS times ANS-- oh, which way did I want to do this x - is less than or equal to x. Now that's a test.
首先进行终结测试,因此流程图就的去,传统的做法是把这个放到一个菱形里面,检查下是否ANS乘以ANS-哦,我刚才是怎么说的来着-是不是小于等于。
Check first is N less than 2.
首先检查N是否小于。
应用推荐