`
Dev|il
  • 浏览: 121816 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论
文章列表
        初学javascript,就想动手重写下alter和confirm,自带的真的太丑了,刚看了javascript oo写法,就想着模仿一下,直接上代码 //消息对话框 var MessageBox = (function () { var Msg = { baseUrl: "", //初始化函数 init: function () { this.omask = null; this.messageBox = null; this.callback ...
回溯法是设计递归过程的一种重要方法,它的求解过程是遍历一个状态树,只是这颗树不是预先建立的而是隐含的遍历过程,在遍历过程中对各个元素进行取舍。 如求n个元素集合的子集,如A = {1, 2, 3}则A集合的子集有:   PrA = {{1,2,3}, {1,2}, {1,3},{1},{2,3},{2},{3},{}} 遍历过程中的状态树: #include <iostream> #include <stack> using namespace std; const int _N = 1000; int list[_N]; int n; vo ...

螺旋矩阵

 
给一个正整数n,输出一个n*n的螺旋矩阵 螺旋矩阵可以是逆时针也可以是顺时针,也可以是从里到外,也可以是从外到里 顺时针,从外到里: #include <iostream> using namespace std; const int _N = 100; int matrix[_N][_N]; //思想:递归每一圈 /* 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 */ void setMatrix(int x, int y, int start, int n) ...

Huffman编码

最优二叉树(Huffman树) 首先给出路径和路径长度的定义: 从树的一个结点到另一个结点之间的分支构成这两点之间的路径,路径上的分支数目叫路径长度,树的路径长度为从根到每一个结点的路径长度之和。 带权路径长度:为该结点到跟的路径长度和结点上权的乘积。 树的带权路径:根到每一个结点的路径长度和结点上权的乘积之和。 其中带权路径长度WPL最小的二叉树称为最优二叉树或赫夫曼树. 如何构造Huffman树:   1.根据给定的n个权值{w1,w2,w3,w4....wn}构造n颗二叉树集合f(t1,t2,t3...tn} 其中每颗二叉树ti中只有一个带权w1的根结点,其左右子树为空。   2.在f ...
The order of a Tree Problem Description As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1.  insert a key k to a empty tree, then the tree become a tree with only one node; 2.  insert a key k to a nonempty tree, if k is less than the roo ...
Binary Tree Traversals Problem Description A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important ways in which the vertices of a binary tree can be systematically traverse ...
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1622 Trees on the level Problem Description Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines' CM-5 are based on fat trees. Quad- and octal-trees are fundamental to many algo ...
病毒侵袭 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2557    Accepted Submission(s): 667 Problem Description 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻。。。。在这样 ...

HDU 2203(亲和串)

    博客分类:
亲和串 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2486    Accepted Submission(s): 1116 Problem Description 人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现,现在长大了却不知道怎么去判断亲和串了,于是他只好又再一次来请教聪明且乐于助人的你来解决这个问题。 亲和串 ...
Trie树   Trie树,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计和排序大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:最大限度地减少无谓的字符串比较,查询效率比哈希表高。    Trie是一颗存储多个字符串的树。相邻节点间的边代表一个字符,这样树的每条分支代表一则子串,而树的叶节点则代表完整的字符串。和普通树 不同的地方是,相同的字符串前缀共享同一条分支。还是例子最清楚。给出一组单词,inn, int, at, age, adv, ant, 我们可以得到下面的Trie: tire树的查找时间复杂度为O(n) 实现代 ...

HDU2060(Snooker)

Snooker Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3298    Accepted Submission(s): 1383 Problem Description background: Philip likes to play the QQ game of Snooker when he wants a relax, though he was just a little vegetable-bird. Maybe ...
敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9597    Accepted Submission(s): 4072 Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清 ...
参考资料:http://www.cppblog.com/MiYu/archive/2010/08/29/125199.html 此题的simple建立的树为: AC代码: #include <iostream> using namespace std; const int _N = 200005; int a[_N << 2]; int max(int b, int c) { return b > c ? b : c; } //跟新父节点的值 void pushUp(int rt) { a[rt] = max(a[rt &l ...
/** ** name: 二叉树的创建和遍历 ** author: Dev|il ** date: 2011-10-15 12:56 **/ #include <iostream> #include <queue> using namespace std; const int MAX_TREE_SIZE = 1000; typedef int ElemType; typedef bool Status; typedef ElemType bitTree[MAX_TREE_SIZE]; //树的线 ...

HDU1686Oulipo

 
Oulipo Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1554    Accepted Submission(s): 587 Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulip ...
Global site tag (gtag.js) - Google Analytics