0-1背包问题i = 1,扫所有上限价钱只购买一件物品的最大消费(price[1])i = 2,更新一遍,此时是购买两件物品的最大消费(price[2])以此类推~有n件物品但是只进行到n-1,是因为最大的那件物品留至最后才减价值最高上限为m-5 1 #include 2 #include 3 #i...
分类:
其他好文 时间:
2014-07-31 23:45:10
阅读次数:
225
早期的编程语言如FORTRAN、C基本上都是面向过程的语言,其编程的主要思路专注于算法的实现。例如下面是一个面向过程的求正整数最大值的程序: int maxSoFar=0,price=1; //最大值maxSoFar的初始值为0,price是输入的值 while(price>0){ ...
分类:
其他好文 时间:
2014-07-30 11:47:53
阅读次数:
217
题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may com....
分类:
编程语言 时间:
2014-07-30 05:35:13
阅读次数:
260
题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may com....
分类:
编程语言 时间:
2014-07-30 05:35:03
阅读次数:
309
题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transact....
分类:
编程语言 时间:
2014-07-30 05:34:13
阅读次数:
248
Little Bob loves chocolates, and goes to the store with $N money in his pocket. The price of each chocolate is $C. The store offers a discount: for ev...
分类:
其他好文 时间:
2014-07-29 20:35:22
阅读次数:
306
题意:有关用硬币凑成所需面值的组合数。
1、只有N,表示使用个数从1 - N的硬币凑成面值为N的组合数
2、N,L1,表示使用个数从1 - L1的硬币凑成面值为N的组合数
3、N,L1,L2,表示用个数从L1 - L2的硬币凑成面值为N的组合数
思路:这题用到了Ferrers图像的性质,即将整数N拆分成不超过n个数之和的拆分数的方案数与将整数N拆分成若干数但都不大于n的方案数是相同...
分类:
其他好文 时间:
2014-07-29 15:08:18
阅读次数:
200
本文继续沿用第三章的 XML 示例文档。选取价格高于30的 price 节点# 从父节点进行筛选>>> root.xpath('//book[price>30]/price')[]# 直接对 price 进行筛选>>> root.xpath('//price[text()>30]')[]选取 pri...
分类:
编程语言 时间:
2014-07-28 11:30:00
阅读次数:
336
XPath 中支持的运算符# | 或: 返回所有 price 和 title 节点集合>>> root.xpath('//price|//title')[, , , ]# + 加法:返回所有 price 子元素前两个之和>>> root.xpath('//price[1]/text() + //pr...
分类:
编程语言 时间:
2014-07-27 10:56:12
阅读次数:
323
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2014-07-27 09:49:52
阅读次数:
237