自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(86)
  • 收藏
  • 关注

原创 我的vimrc配置

必备vim8.0vim-plugvim-goYCMgotagsctagsset nocompatibleset numbersyntax onset t_Co=256filetype indent onset cursorlineset textwidth=160set hlsearchset incsearchset noerrorbellsexecute pa...

2019-04-08 20:11:51 310

原创 c++ 源码 之 标准库min与max

我觉得学习是需要正反馈了如果觉得标准库源代码很难读懂的话是时候出现一些给予自己正反馈的内容来看在 < bits/stl_algobase.h >里的min与max /** //作者的注释说了,这里就是做了 你觉得的哪些东西 * @brief This does what you think it does. * @ingroup sor...

2018-06-23 09:28:39 2776

原创 c++ 源码 之 operator new 续

正如我之前在 谈到new所说的我们可以重载 operator new这个函数并且我们希望通过代码来验证talk is cheap实验一 new expression 会调用构造函数实验二 从载operator new 函数可以改变new的过程c++ 真是一门帅气的语言 ,这样我们可以自己接管new的过程 ,并且只有当类型是我们希望的类型才会重载。是不是很像变魔术...

2018-06-21 22:00:15 547

原创 c++ 源码 之 标准库new , operator new , placement new , array new

在c++中管理内存的一些手段与细节那么这篇博客的内容主要是在学习了jjhou老师的内存管理后我自己总结的一些知识点,关于侯捷老师的内存管理的内容可以自己搜索那么直接进入正题了1.new和operator new依照bjarne的c++ programming language的11.2.3章节所说,new ,delete,operator new,operator delete...

2018-06-21 17:25:40 2999

原创 c++ 源码 之 辨准库swap

写这篇文章的原因,希望自己能在技术的道路上越走越远,在一年前使用c语言写了些数据结构后,学会了使用工具的stl,但是希望自己能在源码上对自己使用的stl更加的深入了解,由于本人的学识浅薄,如有错误,还望摘正首先我们要有stl source code 使用github下载git clone https://github.com/gcc-mirror/gcc如果没有安装git使用上...

2018-06-20 10:47:49 1490

原创 LeetCode 847. Shortest Path Visiting All Nodes

这周lc比赛最后一题比较复杂拿出来说下An undirected, connected graph of N nodes (labeled 0, 1, 2, ..., N-1) is given as graph.graph.length = N, and j != i is in the list graph[i] exactly once, if and only if nodes i...

2018-06-06 16:14:21 1110

原创 图论(三) -- 最短路径基础

那么这个系列也许久没有更新 今天与大家谈论的是经典的最短路径问题1.先提出需要记住的概念方便后面的理解,许多内容参考算法导论以及eric的视频1.最短路径的表示2.路径权值和3.图的表示4.源点使用的记号s2.接下来证明一条最优子结构 – 最短路的子路径一定最短反证法:主要思想 在子路径贴上一条比以前短的路径,一定会用更短的这条替代之前那条,所以最短路的...

2018-06-06 14:44:16 514

原创 小实验证明 (编译器g++)定义在c++类中函数均为内联函数

看bjarne的c++中说明 类中函数均为内联 ,前段时间正好有与同学讨论这点,这里做个实验证明 ,由于鄙人水平浅薄,如有错误,还望摘正第一个实验证明优化为O0时内联是不生效的首先关掉优化 证明当优化为O0时 所有内联均被忽略这里可以学习到两个东西1.c++中的函数 在调用时的符号与c有明显的区别2.编译器优化为O0的时候内联不生效第二个实验证...

2018-05-15 12:07:00 719

原创 csapp实验二 ---bomb(第五关)

keep moving来到第五关gdb bomb disas phase_50x0000000000401062 <+0>: push %rbx0x0000000000401063 <+1>: sub $0x20,%rsp0x0000000000401067 <+5>: mov %rdi,%rbx0x00...

2018-05-10 10:38:52 1100 1

原创 csapp实验二 ---bomb(第四关)

再接再厉来到第四关gdb bombdisas phase_4看一看到什么东西送到esi并且做为sscanf的第二个输入先看下是什么(gdb) x/s 0x4025cf0x4025cf: "%d %d"那么这题就是输入两个数接下来判断第一个数小于等于14我们才能接着游戏调用func4 入口参数 第一个参数 第一个数 第二个参数...

2018-05-10 10:04:22 1001

原创 csapp实验二 ---bomb(第三关)

继续来gdb bombdisas phase_3 我们看到 有个诡异的东西放进esi了 先看看x/s 0x4025cf得知”%d %d” 注意到栈顶+8是rdx也就是接受输入的地方然后输入后判断输入数量是否正确然后开始判断第一个数是否减上7后是否还是>0不是立马爆炸接着是*0x402470(,%rax,8)注意rax是我们第一个数的值x/a 0...

2018-05-09 19:23:32 749

原创 csapp实验二 ---bomb(第二关)

解决了第一个问题后来到phase_2gdb bomb disas phase_2输入仍然是input 在 rdi中然后开了40字节的缓冲区接着把栈头地址丢给rsi调用read_six_number 顾名思义但是我们还是看看disas read_six_numbers在read_six_numbsers中我们看到作为sscanf的第二个参数esi...

2018-05-09 18:09:11 629

原创 csapp实验二 ---bomb(第一关)

写在前面,4月24号,微软实习三面失败后,决定继续发奋图强,写在这里给自己一个警醒,也希望以后能更技术能越来越好,以前的博客质量上可能还有欠缺,将在以后的时间里重新编辑准备工作1.环境准备有docker下载我准备好的实验镜像docker pull liutianhao/csapp_bomb没有docker请确保有gdb和gcc等工具2.文件准备前面的博客...

2018-05-09 17:23:00 826

原创 csapp实验一部分答案

csapp 部分答案/* * CS:APP Data Lab * * <Please put your name and userid here> * * bits.c - Source file with your solutions to the Lab. * This is the file you will hand in to your in...

2018-05-03 11:22:14 1344

原创 csapp的实验一 如何使用以及答案(一)

被大学室友安利此书后 现在看到第三章 确是一本好书(缓冲区溢出攻击尤为精彩,而且推荐给我看此书的人绝对没有细看这本书) 那么这本书配套的实验也是十分有意思大部分网上都是答案这里使用方法也说明一下csapp网址 下载后解压解压后bits.c是我们需要解决的内容主要说一下如何编译和测试在readme中那么我这里是使用docker下的...

2018-02-28 09:38:11 14096 6

翻译 powershell中和hyper-v的api(二)

4.CheckPoint-VM命令创建检查点用CheckPoint-VM创建了检查点 指定检查点名称的创建方法5.查看建立的检查点6.应用检查点7.删除检查点

2018-02-24 10:05:28 998

翻译 powershell中和hyper-v的api(一)

在stackoverflow中逛,无疑中发现帖子中推荐的有意思的东西原文地址那么也不是完全的翻译,用自己本地做的一个给大家看看 首先用管理员身份运行powershell这就不上图了1.get-vm 使用get-vm观看目前所有的虚拟机使用 使用get-vm观看指定虚拟机的信息使用get-vm观看正在运行的虚拟机更深入的用法2.Start-VM ...

2018-02-23 13:12:59 3439

原创 多叉树(二叉树)的递归与非递归的后序遍历

之前说过前序遍历 这次我就教教大家如何用前序遍历的方法搞定后序遍历之前写过的结构体不再重复书写了void dfs( TreeNode *root ){ if( root == NULL ) return ; dfs( root->left ); dfs(root->right ); cout root->valendl ;}

2018-01-25 21:08:55 1521

原创 二叉树的递归非递归实现的中序遍历

和前序遍历类似这次我们不引入多叉树的概念(因为你不能判断你在哪个中间不像二叉树,所以不引入多叉树的的中序遍历)首先定义树的结构struct TreeNode { int val ; TreeNode *left; TreeNode *right ; TreeNode( int _val ){ val = _val; left

2018-01-24 19:30:18 424

原创 多叉树(包括二叉)如何用栈和递归两种方法前序遍历

算法学习所学习的永远不是代码而是思想首先说二叉树的前序遍历 定义二叉树的结构体(类)calss TreeNode{public: int val ; TreeNode *left ; TreeNode *right ; TreeNode ( int _val) { val = _val ; left == NULL

2018-01-24 13:11:56 573

原创 图论(二) - 并查集相关题目和代码

题目There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then

2017-12-29 14:03:00 172

原创 图论知识和代码(一)

写在前面:这段时间到年末了,准备写点博客复习下以前学的一些知识,那么就先从图论开始吧图论目录1.并查集2.最短路3.拓扑排序4.生成树5.二分图6.欧拉路7.网络流8.连通性这是我准备说的一些东西提前告诉大家那么先从并查集开始吧 这里假定大家已经知道什么是图,包括顶点,边,邻接表 , 邻接矩阵等基本的概念并查集——又叫union find , disjoint set网上有很多关于并查集的博客,

2017-12-16 16:49:58 851

原创 RSA公钥算法是怎么回事(二)

上一节的内容中我们说了如何验证RSA中随机挑选的素数然后我们根据两个大素数p和q (p!= q ) ,例如素数p和q然后 n = p*q , 然后φ(n)=φ(p) * φ(q) = (p-1) * ( q-1 ) 记住n = p * q 这个数会用到然后选取与φ(n)互质的奇数 e (比φ(n)小)然后我们要求解 e*d 和 1 mod(φ(n)) 同余利用上面的结论求解 d 那么在线性同余方

2017-12-06 21:01:23 890

原创 RSA公钥算法是怎么回事(一)

在计算机网络中,公钥密码系统在数字签名与保障信息机密有着重要的作用目前最流行的是RSA公钥算法,今天我们来聊聊这个算法是怎么回事篇幅较长第一步:生成大素数在rsa公钥的初始阶段 , 需要生成两个大素数 p 和 q 如何生成大素数我们先来看费马小定理 – 对于质数p和任意整数a,有a^p ≡ a(mod p)(同余)。反之,若满足a^p ≡ a(mod p),p也有很大概率为质数。将两边同时约去一个a

2017-12-05 20:31:09 813

原创 leetcode weekly contest 61 ( 740. Delete and Earn )

Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums

2017-12-05 14:26:37 723

原创 leetcode weekly contest 61(739. Daily Temperatures)

Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this i

2017-12-05 14:15:15 875

原创 leetcode weekly contest 61 ( 738. Monotone Increasing Digits )

Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits.(Recall that an integer has monotone increasing digits if and only if each pair o

2017-12-05 14:06:00 351

原创 说说DNS在wireshark里的抓包内容(二)

DNS响应的包 首当其中的是事务ID其次我们可以看到 QR 项为1 (区别于查询的包)接下来是Opcode 为 0 ( 通常都为 0) 然后是AA表示授权回答 然后是TC = 0 表示不可UDP包不可截断RD = 1表示 期望递归RA = 1 表示 递归可用后两项不说了 然后是RCODE 是 错误码 这里是0 代表没有错误随后的4个字端构成了DNS 消息的问题 , 回答, 授权 和额外信息 区段

2017-11-06 15:16:15 871 1

原创 说说DNS解析在wireshark里抓包内容(一)

这是我连接leetcode时的抓包先看no1的包然后下拉到DNS头部 首先看到Transaction ID (事务ID) 在TCP/IP协议中370说到在固定长度的头部中, 事务ID字段由客户端设置 , 由服务器返回。 客户端(我们) 用它来匹配相应和查询。 接下来是标志QR 查询是0 响应是1 我们这里是查询 前面也能看到接下来是Opcode 就三个值0000 》 0 代表标准查询 0100

2017-11-02 14:59:02 5013

原创 说说TSL协议里wireshark的抓包内容(三)

看75号报文看到这事握手协议里的Client key Exchange里面有协议内容长度还有公钥的长度 和公钥接着76号报文change cipher spec 说明现在报文通信是加密的然后是报文77加密的握手信息接着服务器回复Client key Exchange (后面没有抓到,可能我停的早了-。-)但是这三篇博客对应的图这图是转载博客http://kb.cnblogs.com/page/197

2017-11-02 11:10:35 621

原创 说说TLS协议里的wireshark抓包内容(二)

第编号70的报文 这是服务器第一次回给客户端的第一个报文 这个报文的内容是server hello里面包括了 内容是握手协议 ( 和client hello )一样版本是TLS v1.2然后是握手协议的类型 server hello接着是服务器生成的随机数( 后面单独说这个)服务器生成的会话ID确认客户端发来的密码套件确认压缩方式这里是null接着我们看第二个报文这份报文里 再说明这是握手协议后

2017-11-01 15:37:14 1376

原创 说说TLS协议里的wireshark抓包内容(一)

我们看到第63号 客户端向服务器发送 Client Hello 数据包我们观察内容先看到 content type 内容的格式 其实就是说这是握手协议中的 Client HelloTLS中有四种协议 握手协议(22) 这里就是22可以看到警告协议(21) , 密码变更协议(20) 这协议没有出现在我们这次的报文里然后是版本号TLSv1.0(这里TLSv1.2可以兼容v1.0)然后是长度然后是握手

2017-10-31 14:29:53 3110

原创 LeetCode Weekly Contest 56 Find K-th Smallest Pair Distance

题目Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B.Example 1: Input: nums = [1,3,1]

2017-10-31 09:54:05 270

原创 LeetCode Weekly Contest 56 第三题

题目Maximum Length of Repeated Subarray My SubmissionsBack to Contest User Accepted: 778 User Tried: 1121 Total Accepted: 744 Total Submissions: 1920 Difficulty: Medium Given two integer arrays A

2017-10-31 09:41:50 164

原创 weekly contest 56 第二题 443. String Compression

题目String Compression My SubmissionsBack to Contest User Accepted: 1210 User Tried: 1446 Total Accepted: 1223 Total Submissions: 3403 Difficulty: Easy Given an array of characters, compress it in

2017-10-31 09:36:16 492

原创 weekly contest 56 第一题 1-bit and 2-bit Characters

题目We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).Now given a string represented by several bits. Ret

2017-10-31 09:29:51 172

原创 weekly contest 55 第三题 Subarray Product Less Than K

题目Your are given an array of positive integers nums.Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k.Example 1:Input: nums = [1

2017-10-23 15:39:36 590

原创 weekly contest 55 第二题Minimum ASCII Delete Sum for Two Strings

题目Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat"Output: 231Explanation: Deleting "s" from "sea" adds the

2017-10-23 15:17:19 125

原创 weekly contest 55 Best Time to Buy and Sell Stock with Transaction Fee

题目Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee.You may complete as many t

2017-10-23 14:21:20 1152

原创 动态规划hard--639. Decode Ways II

题目A message containing letters from A-Z is being encoded to numbers using the following mapping way:'A' -> 1'B' -> 2...'Z' -> 26Beyond that, now the encoded string can also contain the character '*

2017-10-18 16:37:40 221

空空如也

空空如也

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

TA关注的人

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