自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小梁的编程学习之旅

本博客主要是为了促进编程学习,不断总结知识,希望在未来的日子做一个合格的好码农

  • 博客(72)
  • 收藏
  • 关注

原创 POJ 1699- Best Sequence (DFS+查表法)

题目链接题目大意:    给定N个基因片段,每个片段的长度在1到20之间,注意:每个片段长度不一样啊,我一开始以为都为N!求去除重叠基因后字符串的总长最小值解题思路:    全排列问题啊!将所有的基因片段全排列,两两计算重复的字母个数(模拟即可),最后计算出去除重复基因总长,选择最小值。典型的DFS问题,但是就因为计算两个基因片段的重复字母数,整整搞了一天!现在看来还是

2017-05-09 16:57:46 585

原创 POJ 1321-棋盘问题(DFS)

题目链接题目大意:    中文题目无需解释吧!解题思路    利用DFS按行扫描即可,注意是 "#"的地方才能放棋子,可能有的行没有"#",也可能可以放棋子的地方多于棋子数。题目中遇到比较坑爹的地方就是-每一行都可以放或不放棋子,就因为没有考虑到这种情况,导致提交代码一直WA。#include #include "stdio.h"using name

2017-05-09 16:47:32 205

原创 POJ 2362 Square-(DFS+ 剪枝)

题目链接题目大意:    给定一组木棍长度的数据,求是否能拼成一个正方形.解题思路:    简单的DFS遍历就好了,但是本题要考虑剪枝    1)当所有木棍长度和sum, 需要满足sum%4 = 0,否则拼不成正方形。    2)最长的木棍要满足小于边长side = sum / 4。    在1)2)条件下进行DFS遍历,可以减小时间复杂度。

2017-05-09 11:56:58 220

原创 POJ 1416-Shredding Company

题目大意:公司现在要发明一种新的碎纸机,要求新的碎纸机能够把纸条上的数字切成最接近而不超过target值。比如,target的值是50,而纸条上的数字是12346,应该把数字切成四部分,分别是1、2、34、6。因为这样所得到的和43 (= 1 + 2 + 34 + 6) 是所有可能中最接近而不超过50的。(比如1, 23, 4, 和6 就不可以,因为它们的和不如43接近50,而12, 34,

2017-05-05 17:37:25 226

原创 POJ 2531-Network Saboteur(DFS)

题目链接题目大意:将一个图的节点分为两部分,求两部分的通信距离最大.解题思路:竟然做了好几个小时,提交到POJ上超时,下面给出代码首先我们将所有的点标记为0(即所有点放在一个集合里),然后取出一个site标记为1(即将该点放在另一个集合里),这是对于和site在一个集合里的点,我们减去他们两个之间的权值,对于不在一个集合里的点,我们加上他们之间的权值。最后的结果

2017-05-05 17:07:37 262

原创 POJ-3278 Catch That Cow

题目见链接:原题大致题意:给定两个整数n和k通过 n+1或n-1 或n*2 这3种操作,使得n==k输出最少的操作次数解题思路:用BFS遍历,只需得到一个最小解就行。 注意的地方:1  剪枝。直接广搜一样等着RE吧= = ,判断下一步是否超出边界,即大于100000或者小于0,否则RE。BFS有固定的解题思路:定义一个队列,然后取

2017-05-04 16:13:48 272

原创 POJ 1915 - Knight Moves

Knight MovesTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 23833 Accepted: 11202Description Background Mr Somurolov, fabulous chess-gamer ind

2017-04-25 16:16:07 235

原创 POJ 1979 - Red and Black

Red and BlackTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 34958 Accepted: 18918DescriptionThere is a rectangular room, covered with square tiles. Eac

2017-04-23 20:05:19 247

转载 数组指针与指针数组

数组指针(也称行指针)定义 int (*p)[n];()优先级高,首先说明p是一个指针,指向一个整型的一维数组,这个一维数组的长度是n,也可以说是p的步长。也就是说执行p+1时,p要跨过n个整型数据的长度。如要将二维数组赋给一指针,应这样赋值:int a[3][4];int (*p)[4]; //该语句是定义一个数组指针,指向含4个元素的一维数组。 p=a;

2016-08-21 15:38:40 162

原创 剑指offer-面试题7

题目:用两个栈模拟队列/*********************** 面试题7 :用栈模拟队列***********************/template class CQueue{public: CQueue(void); ~CQueue(void); void appendTail(const T& node); T deleteHead()

2016-08-07 12:34:45 268

原创 剑指offer-面试题6

题目: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。解题思路:递归实现/*********************** 面试题6 : 重建二叉树***********************/struct BinaryTreeNode{ int Value; BinaryTreeNode* pLeft; BinaryTreeNode* pRi

2016-08-07 10:59:31 190

原创 剑指offer-面试题5

在完成第五题之前我想先复习一下链表的基本操作如下:/************************** struct ListNode { int Value; ListNode* pNext; }***************************/// 链表尾插法// 注意头指针pHead的定义// 判断链表是否为空void AddToTail(Lis

2016-08-07 10:57:18 177

转载 GDB十分钟教程

GDB十分钟教程作者: liigo原文链接: http://blog.csdn.net/liigo/archive/2006/01/17/582231.aspx日期: 2006年1月16日本文写给主要工作在Windows操作系统下而又需要开发一些跨平台软件的程序员朋友,以及程序爱好者。GDB是一个由GNU开源组织发布的、UNIX/LINUX操作系统下的、基于命令行的

2016-08-03 20:12:52 185

转载 Linux makefile 教程

最近在学习Linux下的C编程,买了一本叫《Linux环境下的C编程指南》读到makefile就越看越迷糊,可能是我的理解能不行。            于是google到了以下这篇文章。通俗易懂。然后把它贴出来,方便学习。           后记,看完发现这篇文章和《Linux环境下的C编程指南》的makefile一章所讲述的惊人的相似,只是这篇文章从一个实例切入,在有些地方比

2016-08-03 17:18:43 221

原创 CCTYPE函数系列

#include 的函数c++中应该是#include c中应该是#include 以下为字符函数库中常用的函数:函数名称返回值isalnum()如果参数是字母数字,即字母或数字,该函数返回trueisalpha()如果参数是字母,该函数返回真isblank()如果参数是空格或水平制

2016-07-16 10:21:51 265

原创 LeetCode(41)-First Missing Positive

问题描述:问题分析:问题求解:

2016-07-08 17:35:51 181

原创 (5) linux中环境变量PATH设置

最近在Ubuntu系统下安装QT4和嵌入式开发环境,由于对linux系统不是特别熟悉,状况不断,问题最多的应该是环境变量的设置。安装的程序包在调用时经常报错,找不到命令,这时应该就是环境变量的设置问题,所以对linux环境变量PATH设置需要总结一下,以后减少这方面的问题。操作系统:Ubuntu 14.04 1、用export命令设置当前session的PATH在登录用户为Matthe

2016-03-29 21:15:08 345

原创 (5) linux中环境变量PATH设置

最近在Ubuntu系统下安装QT4和嵌入式开发环境,由于对linux系统不是特别熟悉,状况不断,问题最多的应该是环境变量的设置。安装的程序包在调用时经常报错,找不到命令,这时应该就是环境变量的设置问题,所以对linux环境变量PATH设置需要总结一下,以后减少这方面的问题。操作系统:Ubuntu 14.04 1、用export命令设置当前session的PATH在登录用户为Matthe

2016-03-29 20:28:11 102

原创 (4)在Ubuntu下创建 QT4嵌入式开发环境

[1]  QT download[2] 在Ubuntu上创建嵌入式ARM开发环境[3] Ubuntu下 嵌入式Qt开发环境的搭建

2016-03-26 11:27:29 448

原创 (3) 嵌入式Linux开发环境的构建

1 主机与目标板结合的交叉开发模式    对于S3C2440开发板,进行嵌入式Linux开发时一般可以分为一下3个步骤。    (1)在主机上编译Bootloader,然后通过JTAG烧入单板。    通过JTAG接口烧写程序效率非常低,适合于烧写空白单板。Bootloader具有串口传输、网络传输、少些flash功能,可以快速地从主机获取可执行代码,然后烧入单板,或直接运行。  

2016-03-23 12:07:51 385

原创 (2) Linux中diff与patch用法

diff命令  diff命令常用来比较文件、目录,也可以用来制作补丁文件。所谓补丁文件就是“修改后的文件”与“原始文件”的差别。  常用的选项如下:1 "-u": 表示在比较结果中输出上下文中一些相同的行,有利于人工定位2 "-r": 表示递归比较各个子目录下的文件3 "-N": 将不存在的文件当作空文件4 "-w": 忽略对空格的比较5 "-B": 忽略对空行的比较  举

2016-03-23 11:18:00 215

原创 (2) Linux中diff与patch用法

diff命令  diff命令常用来比较文件、目录,也可以用来制作补丁文件。所谓补丁文件就是“修改后的文件”与“原始文件”的差别。  常用的选项如下:1 "-u": 表示在比较结果中输出上下文中一些相同的行,有利于人工定位2 "-r": 表示递归比较各个子目录下的文件3 "-N": 将不存在的文件当作空文件4 "-w": 忽略对空格的比较5 "-B": 忽略对空行的比较  举

2016-03-23 10:20:34 108

原创 (1) Linux下解压缩

tar命令tar命令具有打包、解包、压缩、解压缩4种功能,由于解压缩速度快,占用CPU资源少,在linux中使用的频率比较高。常用的压缩、解压缩的方式有两种:1  gzip,通常以“.gz”、“z”结尾的文件是用gzip方式进行压缩的。2  bzip2,以“.bz”结尾的文件是用bzip2方式进行压缩的。后缀名中有中“tar”字样时表示为一个文件包。tar命令有5个常用的选项。

2016-03-22 22:17:21 303

原创 LeetCode(40)-Combination Sum II

问题描述:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in

2016-03-03 19:59:39 194

原创 LeetCode(39)-Combination Sum

问题描述:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unl

2016-03-03 17:12:47 197

原创 LeetCode(38)-Count and Say

问题描述:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is r

2016-03-03 12:00:42 186

原创 LeetCode(37)-Sudoku Solver

问题描述:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.

2016-03-03 10:34:57 145

原创 LeetCode(36)-Valid Sudoku

问题描述:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A part

2016-01-28 21:57:00 205

原创 LeetCode(35)-Search Insert Position

问题描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in

2016-01-28 20:11:00 200

原创 LeetCode(34)-Search for a Range

问题描述:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is

2016-01-28 18:06:04 197

原创 LeetCode(33)-Search in Rotated Sorted Array

问题描述:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the

2016-01-28 14:36:59 215

原创 LeetCode(32)-Longest Valid Parentheses

问题描述:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring

2016-01-28 14:35:30 194

原创 LeetCode(31)-Next Permutation

问题描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowe

2016-01-26 20:49:04 211

原创 LeetCode(30)-Substring with Concatenation of All Words

问题描述:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in wordsexactly

2016-01-26 20:35:55 204

原创 LeetCode(29)-Divide Two Integers

问题描述:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.问题分析:实现除法,不能用乘法,除法和求余1) 用减法,可能会超时。2)在1的基础上优化,将除数翻倍(位运算)分析:题目意思很

2016-01-26 20:33:52 263

转载 字符串匹配之有限自动机

模式匹配问题:给一个字符串text: txt[0..n-1] 和 一个模式串 pattern :pat[0..m-1],写一个函数 search(char pat[], char txt[])打印模式pat在txt中出现的所有位置。通俗点说就是在一个字符串中定位另一个串的算法。例子:1)输入:txt[] = “THIS IS A TEST TEXT”pat[] = “TES

2016-01-26 16:03:35 456

原创 字符串匹配之朴素字符串匹配算法

朴素字符串匹配算法英文叫Brute force,大致意思是暴力求解。该算法通过一个循环找到所有的有效偏移s,该循环对n-m+1个可能的s值进行检测,看是否满足条件P[1..m] = T[s+1..s+m]。其中T为待匹配的文本,P为要匹配的模式,如下图所示(摘自算法导论):

2016-01-26 15:51:06 328

原创 LeetCode(28)-Implement strStr()

题目描述:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.题目分析:在一个字符串中查找另一个字符串,如果查找成功返回字符串头索引,否则返回-1。有两种求解方法:(1

2016-01-26 15:35:17 207

原创 LeetCode(27)-Remove Element

问题描述:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new l

2016-01-26 10:42:08 171

原创 LeetCode(26)-Remove Duplicates from Sorted Array

问题描述:Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this in pl

2016-01-24 22:13:27 186

空空如也

空空如也

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

TA关注的人

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