摘要: 最大堆/最小堆 堆的定义是:n个元素的序列{k1,k2,…,kn},当且仅当满足如下关系时被成为堆 (1)Ki= k2i且 ki>= k2i-1 (i = 1,2,…[n/2])当满足(1)时,为最小堆,当满足(2)时,为最大堆。 若将此序列对应的一维数组堪称是一个完全二叉树... 阅读全文
posted @ 2014-05-26 17:17 daydaycode 阅读(766) 评论(0) 推荐(0) 编辑
摘要: 堆排序 堆排序是利用堆的性质进行的一种选择排序。下面先讨论一下堆。1.堆堆实际上是一棵完全二叉树,其任何一非叶节点满足性质: Key[i]=Key[2i+1]&&key>=key[2i+2] 即任何一非叶节点的关键字不大于或者不小于其左右孩子节点的关键字。 堆分为大顶堆和小顶堆,满足Key[i]>=... 阅读全文
posted @ 2014-05-26 17:09 daydaycode 阅读(243) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge ... 阅读全文
posted @ 2014-05-11 17:35 daydaycode 阅读(281) 评论(0) 推荐(0) 编辑
摘要: The three hands of the clock are rotating every second and meeting each other many times everyday. Finally, they get bored of this and each of them wo... 阅读全文
posted @ 2014-05-10 23:05 daydaycode 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionThe expression N!, read as "N factorial," denotes the product of the first N positive integers, where N is nonnegative. So, for exa... 阅读全文
posted @ 2014-05-06 21:21 daydaycode 阅读(385) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecuti... 阅读全文
posted @ 2014-05-04 09:44 daydaycode 阅读(150) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequence of ... 阅读全文
posted @ 2014-05-04 09:09 daydaycode 阅读(265) 评论(0) 推荐(0) 编辑
摘要: Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个... 阅读全文
posted @ 2014-05-04 09:06 daydaycode 阅读(180) 评论(0) 推荐(0) 编辑
摘要: DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵... 阅读全文
posted @ 2014-05-04 09:03 daydaycode 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28373Accepted Submission(s): 7417Problem Descript... 阅读全文
posted @ 2014-04-29 21:50 daydaycode 阅读(195) 评论(2) 推荐(1) 编辑