自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(62)
  • 资源 (2)
  • 收藏
  • 关注

原创 git教程-使用github进行版本管理

使用github来进行版本管理。 首先如果你要完整地学习git使用,请参见廖雪峰的博客:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 以及对应的git专业书籍。 这篇博文的目的是为了能让你尽可能快的学习如何使用github来参与开源项目,如何使用github来构造自己的一个

2015-06-09 15:23:04 862

原创 leetcode_数组_相关内容2(

1. 169 Majority Element 传送门:https://leetcode.com/problems/majority-element/ 大意:求出出现次数最多的数。 题解:少见的官方给出了题解,并提供了多种思路。建议都试一试。传送门:https://leetcode.com/problems/majority-element/solution/ AC代码:class Solu

2015-05-15 19:25:37 400

原创 leetcode_数组_相关内容_1(48-66-88-118-119)

对于自己之前写的内容应该做更好的梳理。 1. 48:Rotate Image 传送门:https://leetcode.com/problems/rotate-image/   大意:给出n*n的一个矩形,进行90‘顺时针旋转。 题解:1.思路:对矩阵,第i行j列的元素逆转过来后就是另一个矩阵的j行n-i列。 AC代码如下: class Solution { public: vo

2015-05-15 19:00:34 566

原创 leetcode_stringc

1. 先提供一个string里最受欢迎的题目,https://leetcode.com/problems/reverse-words-in-a-string/ 151 reverse words in a string 参加自己之前所写的博客,AC代码如下: class Solution { public: void reverseWords(string &s) {

2015-05-04 22:01:28 546

原创 leetcode_树_相关内容

1.leetcode种对于树的定义如下: /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {}

2015-04-30 21:10:41 437

原创 leetcode_2_two+sum

只能说hash_table的巧妙性: 这是自己在完全不用hash_table的方法下完成的,实在是太麻烦了: class Solution { public: vector twoSum(vector& nums, int target) { vector temp(nums); sort(nums.begin(),nums.end()); int len

2015-04-28 15:44:45 434

原创 leetcode_33_34_二分搜素

传送门:https://leetcode.com/problems/search-in-rotated-sorted-array/ 思路: 这里首先先提供一下自己一开始写的代码: class Solution { public: int binary_search(vector& vec,int begin,int end,int target) { while(begin<=end

2015-04-24 21:01:20 656

原创 leetcode_permutaionu全排列集合_31_46_47_60

这是leetcode上一个很有意思的排列集合 在此之前我想先引用leetcode上discuss里一位仁兄提出的问题: use the function "STL next_permutation" to solve this problem. good or BAD??? 其中最高票的回答是: Definitely raise this concern to your int

2015-04-21 14:56:15 478

原创 leetcode_77_combiantion_78_subsets_90_subsets2

真是有种 “x了狗了”的感觉,DFS这里总是充满了各种各样的问题 最后写的代码可读性和复杂度都差得厉害,虽然AC: class Solution { public: void solve(int index,int cur,vector &res,vector >&ans,vector& num,int k) { if(index==k) { ans.push_back(r

2015-04-19 09:46:27 579

原创 leetcode_38_39_combiantionsum_1+2

传送门: https://leetcode.com/problems/combination-sum/ https://leetcode.com/problems/combination-sum-ii/ 思路: 用的是DFS递归搜索,如果有满足条件,则加入集合,否则弹出。 pop_back()函数一开始写错了。 STL这里太容易混淆了。 第一题AC代码: class S

2015-04-19 08:36:30 605

原创 链表

写这篇文章的目的是因为在刷OJ的过程中发现自己在数据结构基础方面的知识有所欠缺,用STL用的太熟练了。 无论是出于提高编程能力、提高对数据结构的理解,还是应付面试题的需要,都需要系统化这一知识点。 所以结合《数据结构与算法分析—C语言描述》、浙大的MOOC公开课,写了这样一个系列。 在这一过程中我会更多的使用C/C++语言,而非ADT。 链表是最常见的线性结构,包括物理链表(物理上

2015-04-14 21:31:39 542

原创 vector详解

立此留念。 本篇文章来源于《c++ primer》第四版第四章《容器和算法》和http://www.cplusplus.com/reference/vector/vector/ 上的有关英文文档内容 vector是一个类似于数组的容器,可以储存连续的空间。区别在于:compared to arrays, vectors consume more memory in exchange for t

2015-04-12 10:47:39 419

原创 leetcode_135_Candy_贪心

class Solution { public: bool check(vector &rate,vector &num) { int length=rate.size(); for(int i=1;i<length-1;i++) { if(rate[i]>rate[i-1] && rate[i]>rate[i

2015-04-09 17:40:43 411

原创 leetcode_21_merge_sortedlist

传送门: 解题思路:按照依次比较大小的方式来进行计算,当有一个为空后,讲另一个完全接到新的数组上。 第一次提示runtime error时给出的测试用例是{},{},所以多添加了一句if(!l1 && !l2),完全没必要,应该是因为自己最后返回的是cur而不是head的缘故 图书馆闭关,明天试一下如果不是用指针而是用值会怎么样。 AC代码: /** * Definition for

2015-04-07 21:45:07 419

原创 leetcode_37_sudokusolver

传送门:https://leetcode.com/problems/sudoku-solver/ 问题分析:是leetcode_36的进一步表示。 思路是用深度优先来求解:如果这一点不是空白,则进行下一组操作。 如果这一点是空白,则进行九次循环,如果某一次循环满足check的条件并且能够满足solve(cur+1),即之后的所有情况,直到cur==81为止,则return true; 换言

2015-04-07 21:04:02 521

原创 leetcode_36_validsudoku

传送门:https://leetcode.com/problems/valid-sudoku/ 问题解析:这里的valid并不要求一定能解出来,只要满足每一横行、每一纵行、每一个方格内不存在相等的元素就可以。 单元方格很明显是以3为单位的,求出商和余数后遍历九次就可以。 AC代码:class Solution { public: bool check(int x,int y,vec

2015-04-07 20:47:26 482

原创 九度OJ_北邮_1117_字符串

#include #include #include using namespace std; const int maxn=1000; int main(void) { int n,m; int i,j,k,len; string s1,s2; while(cin>>s1) { cin>>s2; i=s2[1]-'0';

2015-03-26 21:34:19 842

原创 ccf_窗口

这道题是第二道,难度肯定不大,但自己一开始思路就走偏了,一直想用vector来模拟,但迭代器实现起来总是麻烦。 最后用数组,A掉。 主要注意从后开始遍历,并且被点亮的窗口会被直接放在数组最后一位上。 AC代码: #include #include #include #include using namespace std; const int maxn=1000; struct Node

2015-03-26 20:28:04 1601

原创 九度-北邮-1473-二进制

传送门:http://ac.jobdu.com/problem.php?pid=1473 思路:按照求二进制数的原理进行模拟 AC代码:#include #include #include #include #include #include #include using namespace std; const int maxn=1000; int num[maxn];

2015-03-22 10:29:31 711

原创 九度-北航-1163-素数

传送门:http://ac.jobdu.com/problem.php?pid=1163 思路:分类判断。是否为素数是一个部分,是否个位为1是一个部分。     第一次WA是因为没有注意到输出的不包括原来的数。sigh~    还可以优化的地方是在index和number这里,但没有太大的必要,这道题给的数据还是太小了。 AC代码:#include #include #include us

2015-03-19 20:56:16 689

原创 leetcode_62_uniquepaths_

总的来说leetcode属于北美互联网求职方式的体现,和国内常见的OJ有很大的不同。现在能感受的的包括: ①提交的只是一个class,而不需要整个文件的源代码。 ②如果发生wrong answer,点击more details会看到你在哪儿错了,而不会像个黑匣子一样只能自己猜。 传送门:https://oj.leetcode.com/problems/unique-paths/ 思路:求路

2015-02-21 11:10:01 407

原创 2.1.7-2.1.10

2.1.7 boolean algebra(代数) I believe that any third-class college CS/EE student have a understanding about the bool.so this chapter will be very simple. Origin:since binary values are at the core of 

2015-02-08 18:38:40 404

原创 hduing1501_判断合并_dfs_数组

#include #include #include #include using namespace std; const int maxn=1000; char s1[300],s2[300],s3[600]; //数组的长度 int len1,len2,len3; int visit[maxn][maxn]; int dfs(int i,int j,int k) { if(visi

2015-01-02 10:52:27 483

原创 昨日再现——2015年1月

2015.1.1 新年的第一天,还是和许多人一样,在图书馆中度过。 人一天早上和下午是精力最好的时间,因为:①丰富的葡萄糖供应,自制力强.②皮质醇密度低,心情不容易低落。 所谓的时间管理,最终还是精力管理,质量=效率*时间。 早起A了不少题,字典树和拓扑排序、欧拉回路再次熟悉了一遍;字符串方面自己做的还好,但基本功有点不扎实,有必要再看《c++ primer plus》。 晚上在看《深入

2015-01-01 21:30:43 481

原创 操作系统_一_A Tour Of Computer Systems_1.1-1.5

How the program translated into other forms? At first ,we should understand about th How the program translated into other forms? At first ,we should understand about the complitation systems. When

2015-01-01 20:29:47 716

原创 hdu_1251_统计难题_字典树

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1251 做到这道题的时候突然想起某乎上的一个问题:如何评价360面试官对trie树的评价? 只能说想象一下一个汉字后面可能接的数目,即使以10个数字作为基准,那花费的空间也是不敢想象的。 代码如下: #include #include #include #include using namespa

2015-01-01 16:18:18 476

原创 hdu_1048_字符串_水

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1048 是在是不能再水的一道题,适合热身练习用。注意它每次都是读取一行,用c语言的gets也可以。 顺便放一下常用的asc码: 0—9: 48—57 A—Z: 65—90 a—z:  97—122 代码如下: #include #include #include #include

2015-01-01 11:10:42 496

原创 hdu_1878_欧拉回路_并查集

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1878 对于无向图来说,判断是否存在欧拉回路,即是否存在一个回路,每个边只走一次就可以遍历所有的边,且不重复。 充要条件为: ①不存在度数为奇树的点 ②存在一条联通路径 对于第一点:我们在每输入一条边的时候,都将对应的两点度数++,最后进行判断。 对于第二点:用并查集来解决,因为如果存在一条路径的

2015-01-01 09:40:27 357

原创 hdu_1285_拓扑排序_

开始的代码: #include #include #include #include using namespace std; const int maxn=1000; //算法的思想自己已经了解了,那么先按照最基本的it来实现 int map[maxn][maxn];int in[maxn];int visit[maxn];//定义入度 int main(void) { int n,m

2014-12-30 11:17:28 492

原创 hdu_2544_路口最短距离_最短路_dijkstra

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2544 解题思路:题意已经非常明显了,这道题用来检测自己对最短路的理解和代码的熟悉程度,早起热身,一次AC。现在看来属于很水的题。 代码如下:#include #include #include using namespace std; const int maxn=1000; const int I

2014-12-30 09:07:11 470

原创 hdu_1874_畅通工程_最短路_dijkstra

!!! 先附上一开始写的代码,测试用例没有问题,但你发现为什么它一直通不过了吗? #include #include #include using namespace std; const int maxn=1000; const int INF=999999; int n,m; int map[maxn][maxn]; int dist[maxn]; void dijkstra(int s

2014-12-29 20:37:06 347

原创 hdu_2072_统计单词数_set_检测字符串

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2072 思路:每输入一行单词,检验有多少个不同的单词 关键在于两点:①单词不要重复 ②注意好空格 自己用作为集合,已经去掉了第一点;再用sstream(参见http://blog.youkuaiyun.com/allianzcortex/article/details/42168259,个人博客之前的说明)去掉

2014-12-28 19:00:19 592

原创 hdu_1879_继续畅通工程_kruscal_prim_再续

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1879 具体代码参见:http://blog.youkuaiyun.com/allianzcortex/article/details/42192829,之前在博客中的畅通工程第一序列。 问题分析: 在原来问题的基础上增加了一个标示位,如果flag=1的话说明已经修建过,flag=0的话说明还未被修建,要求最短路

2014-12-28 15:18:31 504

原创 hdu_1233_畅通工程再续_最小生成树_kruscal_prim

本来差点都要放入”存疑“归档了,午休之后回来仔细检查一下代码,发现测试用例”1 1 2 6“通不过,结果是因为自己在遍历边时用的是 for(i=0;i 每个人写代码一段时间后都会有固定的规范,比如这道题用并查集+kruscal就看到多种写法,有的人是多不喜欢main()里面的函数啊。 Kuruscal代码如下: #include #include #include using namesp

2014-12-27 14:31:53 578

原创 hdu_2570_配置解药_存疑

肯定是精度问题,但不知道错在哪里。 又及:自己写的代码太复杂了,别人写的更简单的很多。 #include #include #include #include using namespace std; const int maxn=1000; int medi[maxn]; int main(void) { int i,j,k; int n,V,W; int T;

2014-12-27 10:50:16 637

原创 hdu_1800_存疑

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1800 水题,但AC不过,个人倾向于是题目的问题。 代码如下: #include #include #include #include #include using namespace std; const int maxn=3005; int s[maxn];int isused[maxn]; i

2014-12-27 09:47:15 376

原创 hdu_1257_贪心_模拟_最小拦截系统

气cry~,思路完全正确,但因为实现时的一系列小问题,花了将近半个小时才A掉。 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1257 思路:每当有导弹来临时:  ①如果没有任何当前的系统可以达到导弹的高度,则在拦截数组里新增一个,并且最大打击高度为导弹高度。 ②如果有能达到导弹高度,则找到最接近导弹的这一点(可以使浪费的高度最小),并将导弹高

2014-12-27 09:02:28 513

原创 hdu_1049_水_模拟

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1049 和贪心没有任何关系,很简单的模拟题: #include #include #include using namespace std; const int maxn=1000; int main(void) { int n,d,u; int i,j,k; while(c

2014-12-26 21:04:11 376

原创 hdu_1009_贪心_换取食品问题

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1009 这道题思路是很简洁的,按照取值从大到小排序,之后依次进行加减。 一开始写的时候习惯性思维按“return weight 自己在上算法课写贪心策略求解的时候,用的是两个for循环下的冒泡排序,现在看来真是:naive~ 代码如下:#include #include #include #inc

2014-12-26 16:38:11 715

原创 标准I/O库_兼_stringstream使用

今天在OJ上刷题的时候偶然间看到关于stringstream的说明,在网上找到一系列非常好的文章。  对应的章节在的第八章“标准I/O库”里出现,所以提前一些写这篇文章。 首先我们都知道c++在用cin读取输入的数值时是以空白符(white)作为标记的,那么为了能够读取出一整行的内容,我们使用如下的语句 string s, getline(cin,s);如果这一行里含有大量的空格符,需要转

2014-12-26 10:15:34 587

Django1.9 官方文档

Django是一个十分强大的 Web 框架,这里提供了 1.9(最新版) 的所有官方文档,希望能帮助大家

2016-02-08

博客md集合

个人的资源博客集合:) 主要内容包括感受/C++primer 等内容

2015-08-21

空空如也

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

TA关注的人

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