自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(66)
  • 资源 (3)
  • 收藏
  • 关注

原创 leetcode 题目列表

# Title Type Difficulty 2 Add Two Numbers List Medium 4 Median of Two Sorted Arrays Binary Search Hard 10 Regular Expression Matching Dynamic Programming Hard

2017-09-10 19:43:26 394

原创 1.PLA算法总结

PLA(Percetron Learning Algorithm):感知学习算法,主要用于解决二维或者高维的线性可分问题,最终将问题分为两类:Yes or No。所谓线性可分就是可以找到一条直线或者一个k-1维超平面将一堆二维或K维数据中两个不同类别数据完美区分。 PLA算法是“错误驱动”的,当我们在训练这个算法的时候,只要输出值是正确的,这个算法就不会进行任何数据的调整,反之,当输出与实际值异...

2018-04-10 23:47:42 1128

原创 项目技术基本知识

一、Agenda 是一个基于命令行的议程管理系统,系统提供用户登录,新用户注册,已注册用户登录后用户可以注销(delete)当前账户,查询(query)用户名单,也可添加(add)、删除(delete)、查询(query)系统中记录的会议安排等管理功能,使用 c++完成,采用 Makefile 编译项目。 1、Makefile是一个文件名为Makefile的文本文件,用于定义项目的编译规则,以便...

2018-04-04 19:05:45 547

原创 考研复试面试题目

面试要准备知识: 要求: 1.准备自己想从事的科研方向以及相关的知识和最新研究成果或前沿问题要有一定了解和关注(数据挖掘前沿知识、问题) 2.熟悉软件开发过程,掌握一种软件开发方法,软件工程相关知识一定要准备面试准备科目: 重要性:毕业设计、研究方向、软件工程、离散数学、操作系统、数据结构、数据库、计算机组成原理、计算机网络、线性代数、高数、程序设计1.对什么方向感兴趣?那...

2018-04-04 18:39:58 21899 9

原创 Sicily1153.马的周游问题

题目链接:http://soj.333.edu.gr/1153 。 思路:这道题目给出的棋盘是8*8,如果用一般的DFS+回溯来做会超时,这里加入了贪心策略,在马跳到某个位置A时,先计算从位置A再跳一步可以到达的所有可能候选位置的可扩展数C(也就是从候选位置处出发可以到达的位置数),然后按照每个候选位置的可扩展数来确定A处优先选择下一步的方向,C越小该方向优先级越高。代码实现如下:#in...

2018-03-21 11:39:24 276

转载 POJ2084.Game of Connections

题目链接:http://poj.org/problem?id=2084。 思路:找规律,发现符合卡特兰数 规律(1,1,2,5,14,42…),卡特兰数的递推式a[i]=a[i-1] * (4*i-2)/(i+1),n最大为100,利用万进制来保存并计算数据。代码实现如下:#include <iostream>#include <cstdio>#include &...

2018-03-21 10:26:29 184

原创 HDU1042.N!

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042。 思路:采用万进制保存结果,参考链接:http://blog.csdn.net/lulipeng_cpp/article/details/7437641。代码如下:#include <iostream>#include <vector>#include &l...

2018-03-20 12:29:37 130

原创 POJ3259.Wormholes

题目链接:http://poj.org/problem?id=3259。 思路:判断Farmer John能否通过虫洞穿越过去见到自己,问题可以转化为判断给定有权图是否存在负权圈,使用Bellman-Ford算法可以判断,代码实现如下:#include <iostream>#include <cstring>#include <vector>us...

2018-03-18 10:39:07 115

原创 POJ1470.Closest Common Ancestors

题目链接:http://poj.org/problem?id=1470。 思路:给出一棵树和多个求两个节点的最近公共祖先的查询,使用tarjan 离线算法应对多对查询,使用并查集来合并顶点,不过这里不能够使用按秩合并,只能将root的所有孩子节点并到root上,代码如下:#include <iostream>#include <vector>#include &l...

2018-03-16 11:12:33 161

原创 POJ3177.Redundant Paths

题目链接:http://poj.org/problem?id=3177。 思路:这道题目给出一个无向连通图,要求至少添加多少条边才能够使得任意一对顶点间至少有两条不同的路径(没有相同的边,但可以有共同的中间顶点),利用tarjan求出该连通图的边双连通分量,压缩成一个点,最后能构成一棵树,那么添加的边数=(树中度为1的节点数+1)/2,代码如下:#include <iostream...

2018-03-16 09:19:32 114

原创 Poj1164.The Castle

题目链接:http://poj.org/problem?id=1164。 思路:这道题目给出了一个城堡的地图,要我们根据地图求出城堡中房间数和最大房间的面积。关键就是利用DFS来求连通分块数,再利用一个全局变量maxArea记录最大房间面积。代码实现如下:#include <iostream>using namespace std;struct G{ int ...

2018-03-14 23:51:00 164

原创 Poj2488.A Knight's Journey(DFS+回溯)

题目链接:http://poj.org/problem?id=2488。 思路:这道题目给出一个p*q棋盘,让我们判断能否按照马走日字的方式走遍整个棋盘,每个格仅访问一次。可以采用DFS+回溯的方法来做,对于当前的位置,先将访问为置为True,然后按照字典序从小到大的顺序依次访问当前位置能够到达的且未被访问的位置,这样便能够保证如果能够成功遍历整个棋盘时所得到的路径是字典序最小的。代码如下:...

2018-03-14 20:57:04 126

原创 Poj1077.Eight(BFS+Canton)

题目链接:http://poj.org/problem?id=1077。 思路:经典的八数码问题。棋盘的每个状态对应一个结点,如果状态A可以通过移动一步得到状态B,则从A到B有一条边。将初始状态放入队列中,开始BFS,一旦生成目标状态,BFS便可停止。对于搜索过程中的去重,可以将全排列中的一个状态经过康托展开转换为一个唯一的数来压缩存储空间,利用一个visit数组来判断遍历到的状态是否已生成。代

2018-01-16 17:01:47 221

原创 Poj2186.Popular Cows(SCC)

题目链接:http://poj.org/problem?id=2186。 思路:利用tarjan构造强连通分量,并统计各强连通分量内节点数目, 然后将各强连通分量当成一个节点对待,构成一个新的图,统计出各节点的出度数,要存在受其他牛欢迎的牛,那么强连通分量构成的图必定是一个连通的DAG,而且该DAG出度为0的节点数有且只有1个,否则是不存在满足题意的牛。代码实现如下:#include

2018-01-16 09:14:21 147

原创 Strongly connected component

思路:这道题目是让我们求出在经过旷日持久的互殴后至少能够留下多少只怪兽。本质是要我们根据怪兽间关系,构造有向图寻找强连通分量。如果有两个强连通分量那么每个强连通分量中至少会有一只怪兽留下,假设一个有向图中强连通分量个数为n,如果强连通分量间互不连通,那么至少能够留下n只怪兽;若两个强连通分量之间存在一条边相连,那个怪兽的数量为n-1。这道题使用Tarjan来寻找强连通分量,代码实现如下:cla

2018-01-15 11:58:50 447

原创 215. Kth Largest Element in an Array

题目:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and k = 2, return 5.

2018-01-13 11:32:22 157

原创 判断有向图是否有环

题目:给出一个有向图,判断图中是否有环。 思路:可以利用拓扑排序来进行判断,有两种,一种是基于Kahn’s algorithm,另一种是基于DFS。具体可以参看:https://en.wikipedia.org/wiki/Topological_sorting。Kahn’s algorithm的大致流程是先将有向图中入度为0的顶点放入队列中,然后开始循环直到队列为空,在循环中,取出队首元素记为i...

2018-01-12 16:26:29 2057

原创 Poj1979.Red and Black(DFS)

题目链接:http://poj.org/problem?id=1979。 思路:简单的搜索问题,利用DFS即可。代码实现如下:#include using namespace std;const int MAXN = 25;char graph[MAXN][MAXN];bool visit[MAXN][MAXN];int w, h, cnt = 0;struct To{

2018-01-12 15:05:59 114

原创 Poj1502.MPI Maelstrom(Dijkstra&Bellman-Ford)

题目链接:http://poj.org/problem?id=1502。 思路:这道题本质是求单源最短路径。Dijkstra算法解决,利用dist数组保存每个顶点到源点的最短路径,利用visited数组标示该顶点是否被访问,每一次更新dist时顺便找出未被访问点到源点的最短路径。代码实现如下:#include #include #include using namespace st

2018-01-10 22:28:54 246

原创 Poj1308.Is It A Tree?

题目链接:http://poj.org/problem?id=1308。 思路:这道题目要求判断所给有向图是否为一棵树(树可以为空),运用并查集来判断加入一条边后是否符合一棵树的性质,具体判断见下面代码:#include <iostream>#include <cstdio>#include <cstring>#define MAXN 100u...

2018-01-09 18:54:58 164

原创 127. Word Ladder

题目:Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed at

2018-01-09 18:35:41 164

原创 129. Sum Root to Leaf Numbers

题目:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total s

2018-01-08 16:37:07 134

原创 124. Binary Tree Maximum Path Sum

题目:Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The

2018-01-08 15:54:24 127

原创 99. Recover Binary Search Tree

题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space is pretty straight forward. Could you devise

2018-01-07 22:50:14 127

原创 98. Validate Binary Search Tree

题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less thanthe node’s key. T

2018-01-07 22:11:20 145

原创 Poj1050.To the Max

题目链接:http://poj.org/problem?id=1050; 思路:这道题目要求出最大子矩阵和,可以将二维矩阵计算转化为一维最大连续子数组和。依次遍历所有行,对于当前行i,分别求出row[i,i+1],row[i,i+1,i+2]…row[i,i+1,…i+n]的相同列j的和保存在对应的temp[j]中,这样就可以将二维矩阵计算转化为一维数组了。代码实现如下:#include

2018-01-07 11:15:48 155

原创 135. Candy

题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on

2018-01-06 21:43:40 165

原创 134. Gas Station

题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to i

2018-01-06 20:35:58 211

原创 45. Jump Game II

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is

2018-01-06 16:52:15 111

原创 55. Jump Game

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if

2018-01-06 15:39:55 180

原创 最小生成树之Prime算法

题目链接:http://poj.org/problem?id=1258 思路:题目本质就是要求最小生成树,根据题目给出的测试数据格式利用prime算法即可,代码实现如下:#include #include using namespace std;const int MAXN = 102;const int INF = 0xfffffff;int graph[MAXN][MAXN

2018-01-06 14:42:27 266

原创 longest common subsequence (LCS)

思路:这道题目给出两个字符串,要求出最长公共子序列。利用动态规划思想,令dp[i][j]表示x[1…i]和y[1…j]的最长公共子序列,状态转移方程为:dp[i][j] = (x[i-1]==y[j-1]) ? dp[i-1][j-1]+1 : max(dp[i][j-1], dp[i-1][j]);代码实现如下:#include #include #include using name

2018-01-06 12:05:36 172

原创 Poj1159.Palindrome

题目链接:http://poj.org/problem?id=1159 思路:这道题目要我们求出将给定字符串变为回文串所需最小插入字符数。利用动态规划思想,令dp[i][j]表示将字符串s[i…j]变为回文串所需插入的最小字符数,状态转移方程为:dp[i][j] = (str[i-1] == str[j-1]) ? dp[i+1][j-1] : (min(dp[i+1][j], dp[i][j-...

2018-01-06 11:38:41 191

原创 最小生成树之Kruskal算法

最小生成树: Kruskal算法描述:该算法是基于贪心的思想得到的。首先我们把所有的边按照权值先从小到大排列,接着按照顺序选取每条边,如果这条边的两个端点不属于同一集合,那么就将它们合并,直到所有的点都属于同一个集合为止。合并顶点可以利用并查集,换而言之,Kruskal算法就是基于并查集的贪心算法。Kruskal算法流程: 1. 新建图G,G中拥有原图中相同的节点,但没有边; 2

2018-01-05 21:29:41 501

原创 An activity-selection problem(Greedy Algorithm)

思路:要求出最大解集,可以将所有活动按照结束时间从小到大排序,然后遍历一遍所有活动,只要当前活动开始时间不小于上一活动结束时间便可加入集合中。这样求出的最大解集只是可行的最大解集的其中一种。 代码实现如下:#include #include #include using namespace std;struct activity{ int s; int f;};

2018-01-05 17:29:53 914

原创 Poj1160.Post Office

题目链接:http://poj.org/problem?id=1160 思路:利用动态规划思想,令dp[i][j]表示i个邮局在前j个村庄的最优解,dis[i][j]表示在村庄V[i…j]之间只有一个邮局时的最优解,显然当邮局处于i,j中间位置时可达到最优解,状态转移方程可以表示为:dp[i][j] = min(dp[i][j], dp[i-1][k]+dis[k+1][j]) (i-1

2018-01-05 13:32:17 199

原创 Poj2663. Tri Tiling

题目链接:http://poj.org/problem?id=2663 思路:这道题目要求我们求出有多少种方法用1*2牌去完美覆盖3*n的棋盘。利用动态规划,dp[i]表示3*i的棋盘的可完美覆盖的总数。我们可以将棋盘分为左右两部分,左边为可分割部分,右边为不可分割的部分。 当i=2时,右边有3*2区域是不可分割的,用1*2牌填铺共有3种方法,可得dp[i]=3*dp[i-2]。 当i=4时...

2018-01-05 10:21:06 172

原创 132. Palindrome Partitioning II

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”, Return

2018-01-04 23:40:02 121

原创 120. Triangle

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”, Return

2018-01-04 23:39:21 141

原创 120. Triangle

题目:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle [ [2], [3,

2018-01-04 20:18:27 117

数字图像处理课件-北京大学研究生本科生通用

这是北京大学数字图像处理的课件,适合于本科生和研究生使用

2018-09-09

数字图像处理课件-北京大学

北京大学数字图像处理课件,这是一份适合于刚接触数字图像处理的新手,内容充实,浅显易懂

2018-09-07

计算机网络自顶向下方法第四版答案(英文版)

计算机网络自顶向下方法第四版答案(英文版)

2016-10-06

空空如也

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

TA关注的人

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