ITeye博客

记录每天的点点滴滴

Dev|il · 共 103 篇文章

基于jquery做的一个弹窗效果

初学javascript,就想动手重写下alter和confirm,自带的真的太丑了,刚看了javascript oo写法,就想着模仿一下,直接上代码 [code="java"]//消息对话框 var MessageBox = (function () { var Msg = { baseUrl: "", //初始化函数 init: function () { this.omask = null; this.messageBox = null; this.callback = null; this.frame = null; this.clientWidth = $(window).widt…

2012-02-21 13:57 · 前端技术 · 评论(0)

求n个元素集合的子集(幂集)或n个元素的组合

回溯法是设计递归过程的一种重要方法,它的求解过程是遍历一个状态树,只是这颗树不是预先建立的而是隐含的遍历过程,在遍历过程中对各个元素进行取舍。 如求n个元素集合的子集,如A = {1, 2, 3}则A集合的子集有: PrA = {{1,2,3}, {1,2}, {1,3},{1},{2,3},{2},{3},{}} 遍历过程中的状态树: [img]http://dl.iteye.com/upload/attachment/573858/4064e4aa-d73b-3708-96c3-b90fc8da49b2.jpg[/img] [code="java"]#include #include u…

2011-10-21 13:19 · 算法设计 · 回溯 · 评论(0)

螺旋矩阵

给一个正整数n,输出一个n*n的螺旋矩阵 螺旋矩阵可以是逆时针也可以是顺时针,也可以是从里到外,也可以是从外到里 顺时针,从外到里: [img]http://dl.iteye.com/upload/attachment/572662/416ffcef-483b-3100-83ba-a52bbc9394f7.jpg[/img] [code="java"]#include 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…

2011-10-19 13:26 · 算法设计 · 评论(0)

Huffman编码

[align=center]最优二叉树(Huffman树)[/align] 首先给出路径和路径长度的定义: 从树的一个结点到另一个结点之间的分支构成这两点之间的路径,路径上的分支数目叫路径长度,树的路径长度为从根到每一个结点的路径长度之和。 带权路径长度:为该结点到跟的路径长度和结点上权的乘积。 树的带权路径:根到每一个结点的路径长度和结点上权的乘积之和。 其中带权路径长度WPL最小的二叉树称为最优二叉树或赫夫曼树. 如何构造Huffman树: 1.根据给定的n个权值{w1,w2,w3,w4....wn}构造n颗二叉树集合f(t1,t2,t3...tn} 其中每颗二叉树ti中只有一个带权w1…

2011-10-18 13:27 · 数据结构 · 树 · 评论(0)

HDU3999(The order of a Tree)

[align=center]The order of a Tree[/align] 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 …

2011-10-09 14:50 · 树 · 评论(0)

HDU1710(Binary Tree Traversals)

[align=center]Binary Tree Traversals[/align] 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…

2011-10-09 13:41 · 树 · 评论(0)

HDU1622(Trees on the level)

题目连接:[url]http://acm.hdu.edu.cn/showproblem.php?pid=1622[/url] [align=center]Trees on the level[/align] 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…

2011-10-09 11:30 · 树 · 评论(0)

HDU2896(病毒侵袭)

[align=center]病毒侵袭[/align] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2557 Accepted Submission(s): 667 Problem Description 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻。。。。在这样的时刻,人们却异常兴奋——我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~ 但网路上总有那么些网站,开始借着民众的好奇心,打着介绍日食的…

2011-09-26 13:46 · 算法设计 · 串 · 评论(0)

HDU 2203(亲和串)

[align=center]亲和串[/align] 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也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现,现在长大了却不知道怎么去判断亲和串了,于是他只好又再一次来请教聪明且乐于…

2011-09-26 13:10 · 串 · 评论(0)

Trie树(单词查找树或键树)

[align=center]Trie树[/align] Trie树,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计和排序大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:最大限度地减少无谓的字符串比较,查询效率比哈希表高。 Trie是一颗存储多个字符串的树。相邻节点间的边代表一个字符,这样树的每条分支代表一则子串,而树的叶节点则代表完整的字符串。和普通树 不同的地方是,相同的字符串前缀共享同一条分支。还是例子最清楚。给出一组单词,inn, int, at, age, adv, ant, 我们可以得到下面的Trie: [img]…

2011-09-21 12:56 · 数据结构 · 树 · 评论(0)

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 you ha…

2011-09-17 19:20 · 算法设计 · 评论(0)

HDU1166(敌兵布阵)

敌兵布阵 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国都掌握的一清二楚,每个工…

2011-09-17 12:55 · 算法设计 · 线段树 · 树状数组 · 评论(0)

HDU1754 I Hate It

参考资料:[url]http://www.cppblog.com/MiYu/archive/2010/08/29/125199.html[/url] 此题的simple建立的树为: [img]http://dl.iteye.com/upload/attachment/555550/5058a6dd-47dc-3329-b201-dffeaf7b056c.jpg[/img] AC代码: [code="java"]#include using namespace std; const int _N = 200005; int a[_N << 2]; int max(int b, int c) {…

2011-09-16 23:40 · 算法设计 · 线段树 · 评论(0)

二叉树的创建和遍历

[code="java"]/** ** name: 二叉树的创建和遍历 ** author: Dev|il ** date: 2011-10-15 12:56 **/ #include #include using namespace std; const int MAX_TREE_SIZE = 1000; typedef int ElemType; typedef bool Status; typedef ElemType bitTree[MAX_TREE_SIZE]; //树的线性定义,只适合存储满二叉树 const ElemType END = -1; //树的二叉链表定义 typed…

2011-09-15 21:50 · 数据结构 · 树 · 评论(0)

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 Oulipo grou…

2011-09-14 22:15 · 算法设计 · 串 · 评论(0)