2017年9月19日

hdu 1698

摘要: 一个语句顺序错了,我弄了2个小时才找到(细心才是王道)这个题是线段树区间更新,区间查询#include#include#define maxn 100000*4+10using namespace std;struct node{ int l; int r; int value; ... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(85) 评论(0) 推荐(0)

hdu 1754

摘要: I Hate It HDU 1754Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 71808 Accepted Submiss... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(70) 评论(0) 推荐(0)

c++实现真值表

摘要: 首先感谢下面两位博主的帖子!我直接搬过来用了,根据这个我改写了c++输出真值表的代码,再次感谢!后缀表达式求值点击打开链接参考资料1:1 后缀表达式的求值将中缀表达式转换成等价的后缀表达式后,求值时,不需要再考虑运算符的优先级,只需从左到右扫描一遍后缀表达式即可。具体求值步骤为:从左到右扫描后缀表 ... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(854) 评论(0) 推荐(0)

cin输入函数

摘要: cin>>a;//a可以是字符串也可以是字符数组cin.get(ch);//sh是字符变量cin.get(a,20);//cin.getline(数组名,长度,结束符) 大体与 cin.get(数组名,长度,结束符)类似。//区别在于://cin.get()当输入的字符串超长时,不会引起cin函数的... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(342) 评论(0) 推荐(0)

hdu 1251(字典树)(3种方法)

摘要: 统计难题Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 39200 Accepted Submission(s): 14274Pro... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(116) 评论(0) 推荐(0)

HDU 2203(KMP算法)

摘要: 亲和串Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14241 Accepted Submission(s): 6308Proble... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(135) 评论(0) 推荐(0)

九度oj 题目1335:闯迷宫

摘要: 题目描述:sun所在学校每年都要举行电脑节,今年电脑节有一个新的趣味比赛项目叫做闯迷宫。sun的室友在帮电脑节设计迷宫,所以室友就请sun帮忙计算下走出迷宫的最少步数。知道了最少步数就可以辅助控制比赛难度以及去掉一些没有路径到达终点的map。比赛规则是:从原点(0,0)开始走到终点(n-1,n-1)... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(152) 评论(0) 推荐(0)

poj3894 bfs+记录路径

摘要: poj3894bfs+记录路径迷宫问题Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5385 Accepted: 3064Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0,... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(96) 评论(0) 推荐(0)

poj 2935 Basic Wall Maze bfs+路径记录

摘要: Basic Wall MazeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2876 Accepted: 1301 Special JudgeDescriptionIn this problem you have to solve... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(94) 评论(0) 推荐(0)

破损的键盘(链表)

摘要: codevs 4650 破损的键盘题目描述 Description 有一天,你需要打一份文件,但是你的键盘坏了,上面的”home”键和”end”键会时不时地按下,而你却毫不知情,甚至你都懒得打开显示器,当你打开显示器之后,出现在你的面前的是一段悲剧的文本。输入描述 Input Description... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(107) 评论(0) 推荐(0)

递归建立二叉树

摘要: 第一次建立二叉树,终于实现了,之前一直看书,非常枯燥,看得想睡觉。现在有兴趣把刚刚落下的东西补起来了。#include#include#includeusing namespace std;typedef struct node{ struct node *leftchild; stru... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(106) 评论(0) 推荐(0)

二叉树的查找

摘要: 实际上跟我上一篇博文重了,这篇多加了查找上一篇文章#include#include#includeusing namespace std;typedef struct node{ struct node *leftchild; struct node *rightchild; ch... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(179) 评论(0) 推荐(0)

排序代码测试(未完成)

摘要: #include#includeusing namespace std;void swap(int &a,int &b){ int tmp=a; a=b; b=a;}void Selectsort(int a[],int n){ int i,j; for(i=0; ia... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(124) 评论(0) 推荐(0)

实现带有头结点的链表

摘要: 首次写博客,请大神不要吐槽 要实现带头结点的链表,重要的是先搞清楚头结点是什么。链表里有几个名词,头指针,头结点,首结点,概念要明白,会区别,弄懂了这一步,链表的开始就没问题了。头指针即是头结点的地址,头结点数据域为空(当然你也可以用头结点的数据域来保存链表结点的个数),指针域的指针指向... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(612) 评论(0) 推荐(0)

二叉树知道前序和中序求后序,知道中序后序求中序

摘要: 今天来总结下二叉树前序、中序、后序遍历相互求法,即如果知道两个的遍历,如何求第三种遍历方法,比较笨的方法是画出来二叉树,然后根据各种遍历不同的特性来求,也可以编程求出,下面我们分别说明。首先,我们看看前序、中序、后序遍历的特性: 前序遍历: 1.访问根节点 2.前序遍历左子树 ... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(1266) 评论(0) 推荐(1)

HDU 2141 二分查找

摘要: 还有http://blog.csdn.net/libin56842/article/details/17336981没做数据结构http://blog.csdn.net/olga_jing/article/details/50912239字典树Problem DescriptionGive you ... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(154) 评论(0) 推荐(0)

图论 邻接矩阵建图+dfs遍历

摘要: 第一次i建图,用的邻接矩阵。#include#include#include#include#include#define inf 65535using namespace std;typedef struct mygraph{ int ver[1000]; int arc[100][1... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(168) 评论(0) 推荐(0)

图论 邻接表建图+dfs

摘要: 上一篇用的是邻接矩阵建图:点击打开链接所以dfs(&G,0)结果为0 2 3 4 1dfs(&G,1)结果为1 2 3 4dfs(&G,2)结果为2 3 4dfs(&G,3)结果为 3 4 dfs(&G,4)结果为4#include#include#include#includeusing name... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(187) 评论(0) 推荐(0)

图论 用广搜搜邻接矩阵

摘要: 用广搜搜邻接矩阵只是从某一点开始搜,如果是遍历全图的话就每个顶点挨个搜一遍#include#include#include#include#include#include#define inf 65535using namespace std;typedef struct mygraph{ i... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(101) 评论(0) 推荐(0)

图论 邻接表广搜

摘要: 上一篇是邻接表dfs:点击打开链接所以bfs(&G,0)结果为0 2 1 3 4bfs(&G,1)结果为1 2 3 4bfs(&G,2)结果为2 3 4bfs(&G,3)结果为 3 4 bfs(&G,4)结果为4#include#include#include#include#includeusin... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(210) 评论(0) 推荐(0)

图论 用prim法求最小生成树

摘要: 我用的是邻接矩阵保存的图测试数据二所用的图如下:具体说明都在下面这段代码里(如果不嫌弃可以仔细阅读)#include#include#include#include#define inf 65535#includetypedef struct Graph{ int vertex[100]; ... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(213) 评论(0) 推荐(0)

图论 迪杰斯特拉dijkstra求最短路径

摘要: 这个测试用的是下面这个图:9 160 1 2 3 4 5 6 7 80 1 10 2 51 2 31 4 51 3 72 4 12 5 73 4 23 6 34 6 94 5 34 7 95 7 56 7 26 8 77 8 4运行结果如下:#include#include#include#incl... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(151) 评论(0) 推荐(0)

计算几何 判断点在直线的左右哪一侧

摘要: 转载于博客:http://blog.sina.com.cn/s/blog_78ea87380101endw.html方法一:采用几何计算,求面积法。转载:http://blog.csdn.net/modiz/article/details/9928955注意向量是有方向的...判断 某一点在直线左右... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(690) 评论(0) 推荐(0)

临时2

摘要: B题import java.io.*;import java.util.*;public class Main { static int day1[]={31,29,31,30,31,30,31,31,30,31,30,31}; static int day2[]={31,28,31,30,31,... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(78) 评论(0) 推荐(0)

二维凸包 Graham扫描算法 +hdu 1392

摘要: 这个链接讲这个算法讲得很好:点击打开链接#include#include#include#include#define eps 1e-12#include#includeusing namespace std;struct point{ double x,y;} ch[100],pp[100]... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(151) 评论(0) 推荐(0)

经典技术书籍

摘要: 从http://blog.csdn.net/u013050857/article/details/58020733转载source:http://blog.jobbole.com/106093/ 这个列表包括了 100 多本经典技术书籍,涵盖:计算机系统与网络、系统架构、算法与数据结构、前端开发、后... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(167) 评论(0) 推荐(0)

hdu 5365 计算几何 给几个点判断是否为正方形

摘要: RunTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionAFA is a girl who like runing.Today,he downlo... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(134) 评论(0) 推荐(0)

数据结构之链式线性表

摘要: 带头结点的#include#include#include#include#include#includeusing namespace std;#define OK 1#define ERROR 0typedef int status;typedef struct LNODE{ int da... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(174) 评论(0) 推荐(0)

HDU 1010 dfs+奇偶剪枝

摘要: dfs+剪枝Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 129536 Accepted Su... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(98) 评论(0) 推荐(0)

数据结构之顺序线性表

摘要: 九层之台起于垒土,千里之行始于足下!数据结构 顺序线性表这个要注意的地方就是线性表中元素编号是从1开始的,但实际储存时却是用相当于数组的方式储存的,元素从0开始储存故可以边画图边理解,下图标上“(reason)”的地方均是这个原因#include#include#include#include#i... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(83) 评论(0) 推荐(0)

POJ 1753 dfs+枚举

摘要: Flip GameTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 46805 Accepted: 20034DescriptionFlip game is played on a rectangular 4x4 field with... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(211) 评论(1) 推荐(0)

HDU 4277 dfs+set去重

摘要: USACO ORZTime Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5547 Accepted Submission(s): 1840P... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(94) 评论(0) 推荐(0)

平衡二叉树

摘要: 平衡二叉树这里停留了很久,费了很大功夫才弄懂。做个笔记比较好。参考以下两位大佬的博客写的:1: http://www.cnblogs.com/fornever/archive/2011/11/15/2249492.html2: http://blog.csdn.net/followmyinc... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(117) 评论(0) 推荐(0)

使用函数查找字符串子串

摘要: 转载自 大佬1. 考虑用标准函数库中 strstr() 函数包含文件:string.h函数名: strstr函数原型:extern char *strstr(char *str1, char *str2);功能:从字符串str1中查找是否有字符串str2,如果有,从str1中的str2位置起,返... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(973) 评论(0) 推荐(0)

数据结构 斐波那契查找

摘要: #include#include#include#include#includeusing namespace std;int f[1005];void init(){ int i,j; f[0]=0; f[1]=1; for(i=2; if[k]-1)k++;//这里执行完... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(144) 评论(0) 推荐(0)

DP入门 最佳加法表达式

摘要: 描述给定n个1到9的数字,要求在数字之间摆放m个加号(加号两边必须有数字),使得所得到的加法表达式的值最小,并输出该值。例如,在1234中摆放1个加号,最好的摆法就是12+34,和为36输入有不超过15组数据每组数据两行。第一行是整数m,表示有m个加号要放( 0#include\#include#i... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(236) 评论(0) 推荐(0)

图论 关键路径

摘要: 测试所用的AOE图如下:算法参考#include#include#include#include#include#includeusing namespace std;int stack2[100],top2;int etv[100],ltv[100];typedef struct NODE{int... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(220) 评论(0) 推荐(0)

ACM训练计划

摘要: 【转】 POJ推荐50题以及ACM训练方案2010-08-21 21:05转载自 wade_wang最终编辑 000lzlPOJ 推荐50题第一类 动态规划(至少6题,2479 和 2593 必做)2479 和 259310151042(可贪心) 114110501080122112602411(稍... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(135) 评论(0) 推荐(0)

动态规划 最长公共子序列LCS

摘要: 状态转移方程如下:刚开始完全不理解当xi!=yj时,为什么Cij要等于以s1作为标准,当前已经s1下标为i(即i不变,j在变化),匹配时s2的j是依次递增的,那么当s1i!=s2j时,那么此时Cij的值就是C[i,j-1]的值以s2作为标准,当前已经s2下标为j(即j不变,i在变化),匹配时s1的i... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(97) 评论(0) 推荐(0)

Floyd最短路

摘要: 用邻接矩阵实现floyd找最短路算法测试所用图如下:#include#include#include#include#include#include#include#define inf 65535using namespace std;struct Graph//用邻接矩阵来保存图{int arc... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(87) 评论(0) 推荐(0)

邻接表拓扑排序

摘要: 测试所用图如下:#include#include#include#include#include#include#include#define OK 1#define ERROR 0using namespace std;typedef struct NODE{int adjvex;int weig... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(512) 评论(0) 推荐(0)

数字三角形(数塔) DP入门

摘要: dp数字三角形(POJ1163)73 88 1 02 7 4 44 5 2 6 5在上面的数字三角形中寻找一条从顶部到底边的路径,使得路径上所经过的数字之和最大。路径上的每一步都只能往左下或右下走。只需要求出这个最大和即可,不必给出具体路径。三角形的行数大于1小于等于100,数字为0 -99//递归... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(340) 评论(0) 推荐(0)

hdu 5533 计算几何 判断是否为正方形

摘要: 原题目链接:Dancing Stars on MeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1797 Accepted Su... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(100) 评论(0) 推荐(0)

导航