自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

R_xiaozhu_Q的专栏

love what i'm loving~

  • 博客(37)
  • 资源 (4)
  • 收藏
  • 关注

原创 STL---priority_queue 优先队列概述。

顾名思义:priority_queue首先是一个queue,那就是必须在末端推入,必须在顶端取出元素。除此之外别无其他存取元素的途径。内部元素按优先级高低排序,优先级高的在前。缺省情况下,priority_heap利用一个max-heap完成,后者是一个以vector表现的完全二叉树。我们说优先队列不是一个STL容器,它以底部容器而实现,修改了接口,形成另一种性质,这样的东西称之为适配器(

2013-06-29 21:12:17 1022

原创 STL---heap概述,make_heap,sort_heap,pop_heap,push_heap。

heap并不属于STL容器组件,它分为 max heap 和min heap,在缺省情况下,max-heap是优先队列(priority queue)的底层实现机制。而这个实现机制中的max-heap实际上是以一个vector表现的完全二叉树(complete binary tree)。二叉堆(binary heap)就是i一种完全二叉树。也即是。整棵二叉树除了最底层的叶节点以外,都是填满

2013-06-29 20:42:11 3503

原创 编程珠玑---读书笔记---使用后缀数组查找最长重复子串

后缀数组是一个字符指针数组,数组中指针所指的对象包含了字符串的每一个后缀,因此成为后缀数组。看代码:#include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#defi

2013-06-25 16:21:25 960

原创 编程珠玑---读书笔记---堆的实现及堆排序

堆是用来表示元素集合的一种数据结构。与“堆内存”不同。堆的性质,第一:顺序性:任何结点的值都小于或者等于其子结点的值,这意味着最小元素位于根结点。最大顶堆跟这个相反。第二个性质是形状:一种二叉树,最底层的叶子结点尽可能靠左分布,如果有n个结点,那么所有结点到根的距离不会超过logn。下面用vector来实现堆:我们规范的从下标1开始,函数定义如下:root=1;value(i)

2013-06-25 15:11:35 1276

原创 编程珠玑---读书笔记---生成随机整数的有序子集

第一种:使用STL实现,这种现成的数据结构能使代码非常简便,每次插入操作都在O(logm)时间内完成,而遍历集合S需要O(m)的时间,所以完成的程序需要O(m logm)的时间(mx相对于n较小事),但是这种数据结构的空间开销却很大。以下程序实现生成m个0-n内的有序整数子集,第一个算法取m=10,n=100;#include #include #include #include

2013-06-24 19:53:14 1141

原创 编程珠玑---读书笔记---第11章排序

插入排序:对于小型的排序任务速度很快,它是稳定的,只需要O(1)的额外空间,基于比较和交换的次数为O(n^2)。#include #include #include #include #include #include #include #include #include #include using namespace std;int x[8]={55,41,59,

2013-06-24 17:02:25 1067

原创 编程珠玑读书笔记之----->使用线性算法求解连续子序列的最大和

这个算法我在我的博客里使用动态规划做过,具体实现请参阅我的dp板块,下面给出书上最快的算法,时间复杂度为O(n),称之为线性算法。#include using namespace std;int x[10]={31,-41,59,26,-53,58,97,-93,-23,84};int mmax(int a,int b){ return a>b?a:b;}int main(){

2013-06-23 21:36:46 1237

原创 编程珠玑读书笔记之------>一个正确的二分搜索代码

首先确保待查找的元素是处于已排序状态,先给出一个错误的版本,下面这个程序将会陷入死循环:#include using namespace std;const int MAXN=100;int x[MAXN],n,t; //n是数组的长度,t是待查找的元素int binarysearch(int t){ int l,u,m; l=0,u=n-1; while(l<=u) {

2013-06-23 20:38:08 1048

原创 位图排序概要 编程珠玑(第一章)-----学习笔记

位图或者位向量可以表示一系列序列集合,比如:可用一个20位长的字符串来表示一个所有元素都小于20的简单的非负整数集合。例如可用如下字符串表示集合{1,2,3,5,8,13}: 0 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 集合中为1的代表整数集合中的该数。这种表示有一些限制:输入数据限制在相对较小的范围内,数据没有重复,而且对于每条记录而言,除了单一整数外

2013-06-23 10:39:40 1388

原创 庞果网-在线编程挑战 幸运数 简单数论.......

#include #include #include #include using

2013-06-23 00:27:32 2854 7

原创 HDOJ/HDU 2717 Catch That Cow 一维广度优先搜索 so easy..............

看题:http://acm.hdu.edu.cn/showproblem.php?pid=2717思路:相当于每次有三个方向,加1,减1,乘2,要注意边界条件,减1不能小于0,乘2不能超过最大值。然后还要注意N>=K的时候,只能减1才能到达。#include #include #include #include #include #include #include #in

2013-06-22 20:57:47 1066

转载 一些重要的算法------启发式搜索,束搜索(beam search),二分查找算法 and so on............

转自:http://coolshell.cn/articles/2583.html下面是一些比较重要的算法,原文罗列了32个,但我觉得有很多是数论里的,和计算机的不相干,所以没有选取。下面的这些,有的我们经常在用,有的基本不用。有的很常见,有的很偏。不过了解一下也是好事。也欢迎你留下你觉得有意义的算法。(注:本篇文章并非翻译,其中的算法描述大部份摘自Wikipedia,因为维基百科描述

2013-06-19 19:40:43 9301

原创 庞果网-在线编程 人人code,整数取反 字符串流stringstream的简单应用................................

给个题目链接:http://hero.pongo.cn/给个用字符串流做整数取反的代码:#include #include #include #include #include using namespace std;int reverse(int x){ string tmp; int ans; stringstream ss; ss<<x; ss>>tmp;

2013-06-19 19:19:17 940

原创 HDOJ 2391 Filthy Rich dp动态规划.....so easy......

check the pro:http://acm.hdu.edu.cn/showproblem.php?pid=2391see the code:#include#include#include #include #include#include#include#includeusing namespace std;const int maxn=1001;int va[

2013-06-19 14:33:33 701

原创 HDOJ/HDU 2037 今年暑假不AC ...... sth. like interval scheduling use 贪心..so easy...

check the pro:http://acm.hdu.edu.cn/showproblem.php?pid=2037see the code:#include#include#include#include#includeusing namespace std;struct time1{ int start; int end;};bool comxy(time1

2013-06-19 14:24:13 804

原创 HDOJ 1800 Flying to the Mars 盲目搜索......................so easy...........

check the original problem here:http://acm.hdu.edu.cn/showproblem.php?pid=1800the AC code:#include#include#include#include#include#includeusing namespace std;int level[3010];bool visit[301

2013-06-19 14:20:11 812

原创 HDOJ 1257 最少拦截系统 贪心算法again! so easy...........................

check the problem here:http://acm.hdu.edu.cn/showproblem.php?pid=1257the AC code:#include#include#include #include #include#include#include#includeusing namespace std;struct node{ int h;

2013-06-19 14:15:26 710

原创 HDOJ 1051 Wooden Sticks 贪心again! so easy!

check the problem:http://acm.hdu.edu.cn/showproblem.php?pid=1051ac code:(use vector)#include#include#include #include #include#include#include#includeusing namespace std;struct wood{ int

2013-06-19 14:11:48 1046

原创 HDOJ 1050 Moving Tables 贪心so easy!!

click here to check the problem:http://acm.hdu.edu.cn/showproblem.php?pid=1050AC code:#include#include#include #include #include#include#include#includeusing namespace std;struct node{ i

2013-06-19 14:08:49 908

原创 HDOJ 1009 FatMouse' Trade 贪心算法greedy so easy!

看题:http://acm.hdu.edu.cn/showproblem.php?pid=1009代码:#include#include#include #include #include#include#include#include#includeusing namespace std;struct node{ double j,p; double jp;};

2013-06-19 14:05:24 1270

原创 HDU/HDOJ 2612 Find a way 双向BFS

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612思路:从两个起点出发,有多个终点,求从两个起点同时能到达的终点具有的最小时间,开两个数组分别保存两个起点到达每一个终点的用时,最后将两个数组里的时间加起来求最小的一组,必须对应相加,因为终点必须同时到达。#include #include #include #include #

2013-06-19 13:42:18 1148

原创 HDU/HDOJ 2563 统计问题 回溯发DFS

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2563深搜回溯超时,于是可耻的打了个表,0MS AC了。。#include#include#include#includeusing namespace std;int ans[21]={0,3,7,17,41,99,239,577,1393,3363,8119,19601,47321

2013-06-11 14:25:23 1768

转载 HDOJ/HDU 2553 N皇后问题 回溯加递归

回溯法(探索与回溯法)是一种选优搜索法,按选优条件向前搜索,以达到目标。但当探索到某一步时,发现原先选择并不优或达不到目标,就退回一步重新选择,这种走不通就退回再走的技术为回溯法,而满足回溯条件的某个状态的点称为“回溯点”。基本思想:    在包含问题的所有解的解空间树中,按照深度优先搜索的策略,从根结点出发深度探索解空间树。当探索到某一结点时,要先判断该结点是否包含问题的解,如果包含,就

2013-06-11 13:33:42 941

原创 HDOJ/HDU 2141 Can you find it? 二分搜索优化

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2141直接三重循环肯定超时了啊,O(n^3)是不允许的,现在把前两个数组加起来的每种情况保存,再用X-C[i]的值去做二分搜索,这样可以把复杂度降低到O(n^2+nlogn)就可以AC了,不过做二分搜索的时候一定要注意边界情况,不然会WA很多次,尼玛的!!#include#include#inc

2013-06-09 19:30:16 1407

原创 HDU/HDOJ 2102 A计划 广度优先搜索BFS

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2102wa了很多次,很悲剧,传送门有几个需要注意的细节,看remap函数,对这些情况的处理。#include#include#include#include#include#include#include#includeusing namespace std;int n,m,t,f

2013-06-09 15:44:02 1080

原创 HDU/HDOJ 1800 Flying to the Mars 搜索

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1800其实就是求单调最长不降子序列的个数,这题有很多方法,有用map的,有字典树的,我的方法很简单,标记搜索,提交不要选g++,会被卡超时,选c++即可。#include#include#include#include#include#includeusing namespace std

2013-06-07 14:32:47 880

原创 HDOJ/HDU 1728 逃离迷宫 DFS 深度优先搜素

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1728深搜思路:记录4个方向和拐弯次数,若拐弯3次,则必须是当前点和终点在一条直线才满足要求,否则剪掉,这样也超时,坑爹,之前连连看那个题就是用这种方法也能过,z这次的数据有点强,100*100了,所以深搜不行,不过这思路倒不错。代码:#include #include #inclu

2013-06-06 23:50:58 1856

原创 HDU/HDOJ 1677 Nested Dolls 搜索

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1677类似于求最长下降子序列的个数,此题可以用动态规划来解,不过我用简单的搜素来做,可惜超时,先上代码再优化。#include #include #include #include #include using namespace std;struct node{ int w,h;

2013-06-06 00:19:37 1742

转载 HDU/HDOJ 1671 Phone List 字典树的应用

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1671转自:http://blog.csdn.net/zkzxmzk/article/details/8914860;http://www.cppblog.com/hunter/archive/2011/09/30/67039.html;http://www.cnblogs.com/dlutxm/a

2013-06-05 09:03:40 833

原创 HDU/HDOJ 1671 Phone List

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1671没用字典树,思路很简单,用最小的长度去依次匹配前缀即可。时间还需优化,先上代码:#include #include #include #include #include using namespace std;bool cmp(string a,string b){ return

2013-06-04 19:39:48 826

原创 HDU/HDOJ 1548 A strange lift BFS,DFS

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548我用两种方法做,DFS没有AC,不知道错在哪里,贴出来有大神撸过不吝赐教,第二种经典方法BFS过了,76MS 360k,思路都很简单,也是一道很规范的广度优先搜索。代码:BFS:#include #include using namespace std;int n,a

2013-06-04 14:33:51 1349 2

原创 HDU/HDOJ 1372 Knight Moves(骑士游走问题) 简单广度优先搜索

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1372思路:8个方向依次入队即可,只需标记访问,广度优先搜索是按照层次来搜索,如果存在一条通路,那么自然是最短路了。AC代码:62MS 352K,还可以优化。#include#include#include#include#include using namespace std;

2013-06-03 22:58:08 1627

原创 HDU/HDOJ 1312 Red and Black 非常简单的搜索题 BFS

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312题目很好懂,只搜索能到达的地方,统计数量,啥也不做。很坑爹的地方是,行列输入是反的!AC代码:31MS 364K,空间还可以优化,直接不用开visit数组,直接把访问后的点置为障碍即可。#include #include #include #include #include

2013-06-03 13:37:29 1613

原创 HDU/HDOJ 1254 推箱子 嵌套的广度优先搜索

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1254思路:首先要判断人是否能到达箱子所前进的地方的反方向,用第一个bfs1,再判断箱子是否能到达目标点,这是主bfs,箱子每走一步都要调用bfs1,箱子可以从四个方向被推走,开三维数组表示 每个点的四个方向的状态标记,因为可以从上往下腿,也可以从下推回原地,所以二维标记不足以满足。AC代码:0

2013-06-03 09:10:47 1496

原创 HDU/HDOJ 1253 胜利大逃亡 广度优先搜索算法 迷宫寻路

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1253思路:从两维扩展到了三维,使用了三维数组,关于三维数组的理解,可以自己去google,无非就是从平面扩展到了空间,方向也成了6个,前,后,左,右,上,下,其他的都不变,注意一下坑爹的边缘数据就可以了。#include #include #include #include #incl

2013-06-02 12:39:31 1516 1

原创 庞果网 在线编程 24点游戏

“24点游戏是一种使用扑克牌来进行的益智类游戏,游戏内容是:从一副扑克牌中抽去大小王剩下52张,任意抽取4张牌,把牌面上的数(A代表1)运用加、减、乘、除和括号进行运算得出24。每张牌都必须使用一次,但不能重复使用。 有些组合有不同种算法,例如要用2,4,6,12四张牌组合成24点,可以有如下几种组合方法: 2 + 4 + 6 + 12 = 24  4 × 6 ÷ 2 + 12 = 24  1

2013-06-01 13:43:04 2230 3

原创 完美之星编程大赛 复赛第二场 24点

题目描述:描述: 两人用一副扑克(王牌除去)玩24点,规则是这样的:两人各出2张牌,谁先算出来谁赢,赢家收回已经算过的4张牌,最后看谁手里的牌多。四张牌分别用4个扑克牌面字符表示。A,1,2,3,4,5,6,7,8,9,10,J,Q,K 分别代表数字1,2,3,4,5,6,7,8,9,10,11,12,13。其中每张牌只能使用一次;任意使用 +, –, *, /, ( ) ,构造出一个表达式,

2013-06-01 13:18:33 1246

第五届华为创新杯编程大赛--块分配问题

2013年华为第五届创新杯编程大赛决赛试题

2013-05-31

c++primer plus第七章到第十三章习题源码

自己做的答案,全部亲自通过编译。从第七章开始,前面几章在网上能下到全部版本的答案,而从第七章开始却没有

2013-03-12

飞凌ok6410开发板使用导读

使用开发板之前,读次文档能够帮助你勾画一个宏观的轮廓,找得到方向,还有一些注意事项。

2012-10-24

飞凌6410裸机调试教程

基于飞凌公司出产的OK6410,ARM11板子的裸机调试教程,比较初级。 是帮助入门开发板的人。

2012-10-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除