ay 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 at...
分类:
其他好文 时间:
2014-07-13 23:22:16
阅读次数:
294
这里记录下堆的相关操作。
op 1:
'''
@ data: the heap array
@ p : index of parent item
@ n : number of data
@@ Swap p and it's son items, make p the largest of them
'''
def swapForMaxHeap(data, n, p):
l...
分类:
其他好文 时间:
2014-07-13 17:07:15
阅读次数:
223
题目链接:http://poj.org/problem?id=2506
本题用的java解的,因为涉及到大数问题,如果对java中的大数操作不熟悉请点这儿:链接
思路:地推公式f[i]=f[i-1]+2*f[i-2]
code:
import java.math.*;
import java.util.Scanner;
public class Main {
public...
分类:
编程语言 时间:
2014-07-13 16:58:07
阅读次数:
221
Algorithms IN C读书笔记,第一章介绍的解决连通性问题的四个算法...
分类:
其他好文 时间:
2014-07-13 16:54:50
阅读次数:
164
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 complete at most two transactions.
Note:
You ma...
分类:
其他好文 时间:
2014-07-13 13:55:14
阅读次数:
305
Design an algorithm and write code to find the first common ancestory of two nodes in a binary tree. Avoid storing additional nodes in data structure....
分类:
其他好文 时间:
2014-07-13 13:24:21
阅读次数:
279
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of ...
分类:
其他好文 时间:
2014-07-13 13:04:00
阅读次数:
186
题目链接:http://poj.org/problem?id=3468 http://poj.org/problem?id=3468 http://poj.org/problem?id=3468
思路:这是一个区间修改区间查询的题,由于题目中的给的数据比较大,那么用单个修改和查询肯定不行,所以。。。。注意数据可能比较大,应该用__int64或long long存数据。。。。。
code:
#...
分类:
其他好文 时间:
2014-07-12 22:30:01
阅读次数:
168
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1698
题目大意:给你三种硬币,分别面值为1,2,3。初始时,面值都为1,后面没更改一次,就把这个区间的银币换位面值为 X的硬币,最后求所有的硬币面值是多少。
直接贴代码啦
code:
#include
#include
#define L(u) (u<<1)
#define R(u) (u<<...
分类:
其他好文 时间:
2014-07-12 21:29:25
阅读次数:
193
问题
Whoosh是python中解决索引查找的模块,在讨论索引查找的文章已经对有关索引查找进行了阐述,此处详细说明Whoosh模块的应用。
思路说明
Whoosh的安装
这里有详细内容(链接被被阉割!)
whoosh的使用步骤
whoosh在应用上划分三个步骤:
建立索引和模式对象写入索引文件搜索
下面依次阐述各步骤
建立索引和模式对象
建...
分类:
其他好文 时间:
2014-07-12 18:42:42
阅读次数:
545