自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(46)
  • 资源 (1)
  • 收藏
  • 关注

原创 Docker安装及使用

安装及使用Docker安装dockeryum install docker systemctl enable docker systemctl start docker sudo usermod -aG docker cooperpull镜像docker run hello-world docker pull centos docker pull centos:7.2.1511images

2017-07-01 14:19:39 651

原创 KVM安装及使用

本文介绍在CentOS 7.2系统环境的KVM安装及使用,包括NAT网络配置和磁盘添加。KVM安装KVM 是基于CPU 辅助的全虚拟化方案,它需要CPU虚拟化特性的支持numactl –hardware检查是否支持KVM 要支持 KVM, Intel CPU 的 vmx 或者 AMD CPU 的 svm 扩展必须生效a: grep ‘(vmx|svm)‘ /proc/cpuinfovmx是in

2017-07-01 14:03:37 1149

原创 cos签名-xml接口-算法实现

COS签名腾讯云cos xml接口签名文档https://qcloud.com/document/product/436/7778Auth.h    /// @brief 返回cos_xml接口的签名    ///        腾讯云签名文档:https://qcloud.com/document/product/436/7778    /// @pa

2017-04-27 22:21:57 1900

转载 /bin和/sbin

/bin,/sbin,/usr/sbin,/usr/bin 目录 这些目录都是存放命令的,首先区别下/sbin和/bin:从命令功能来看,/sbin 下的命令属于基本的系统命令,如shutdown,reboot,用于启动系统,修复系统,/bin下存放一些普通的基本命令,如ls,chmod等,这些命令在Linux系统里的配置文件脚本里经常用到。从用户权限的角度看,/sbin目录下的命令通常

2017-01-21 23:49:54 1043

原创 systemd - CentOS 7进程守护&监控

需求:运行环境为CentOS 7系统,我们开发了一个程序,需要在开机时启动它,当程序进程crash之后,守护进程立即拉起进程。解决方案:使用CentOS 7中的init进程systemdsystemd简介Linux Init & CentOS systemdLinux一直以来采用init进程。例如下面的命令用来启动服务: $ sudo /etc/init.d/apache2 start 或者\

2017-01-21 23:46:24 12968 5

转载 确保read和write数据完整

write函数write函数定义如下:#include <unistd>ssize_t write(int filedes, void *buf, size_t nbytes);// 返回:若成功则返回写入的字节数,若出错则返回-1// filedes:文件描述符// buf:待写入数据缓存区// nbytes:要写入的字节数同样,为了保证写入数据的完整性,在《UNIX网络编程 卷1》中,

2016-11-17 21:25:17 961

转载 linux send和recv函数详解

#include <sys/socket.h>ssize_t recv(int sockfd, void *buff, size_t nbytes, int flags);ssize_t send(int sockfd, const void *buff, size_t nbytes, int flags);recv 和send的前3个参数等同于read和write。flags参数值为0或:

2016-11-17 21:14:26 391

原创 vim配置

经常重装服务器系统,mark一下。 [moon@earth alien]$ vim ~/.vimrcset nusyntax onset tabstop=4set softtabstop=4set shiftwidth=4set autoindentset cindent

2016-03-17 17:11:40 264

原创 linux常用命令-find和grep区别及使用方法

find和grep区别find用法详解grep用法详解

2016-03-17 16:46:06 6210

转载 轻松学习RSA加密算法原理

http://blog.csdn.net/q376420785/article/details/8557266http://www.ruanyifeng.com/blog/2013/07/rsa_algorithm_part_two.html以前也接触过RSA加密算法,感觉这个东西太神秘了,是数学家的事,和我无关。但是,看了很多关于RSA加密算法原理的资料之

2016-03-10 16:46:05 558

转载 sk_buff

All network-related queues and buffers in the kernel use a common data structure, struct sk_buff.This is a large struct containing all the control information required for the packet (datagram, cell, w

2016-01-19 14:48:34 942

原创 leetcode 233 Number of Digit One

问题:从1到n的整数中1出现的次数Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example: Given n = 13, Return 6, because digit 1 occurred in

2015-10-20 18:13:04 442

原创 KMP算法-字符串匹配

先看看普通字符串匹配BF算法。BF算法BF算法是普通的模式匹配算法,BF算法的思想就是将目标串S的第一个字符与模式串P的第一个字符进行匹配,若相等,则继续比较S的第二个字符和P的第二个字符;若不相等,则比较S的第二个字符和P的第一个字符,依次比较下去,直到得出最后的匹配结果。代码实现:int BFMatch(string s,string p){ int i,j; for(i=0;i

2015-10-20 16:50:36 427

原创 背包问题

背包问题:已知有n种物品,一个可容纳M重量的背包,物品i(1<=i<=n)的重量wiw_i,对应的价值为pip_i。怎样的装包,才能使包中物品的总价值最大?已知条件:n,M,(p1p_1,p2p_2,…,pnp_n),(w1w_1,w2w_2,…,wnw_n)。背包问题分为2种:如果物品可以拆分,就是普通背包问题。如果每个物品不能拆分,就是01背包问题。普通背包问题-贪心算法由于普通背包问题,

2015-10-17 18:50:52 1027

转载 catalan数

算法课最后一节讲到了卡特兰数,总结和学到了很多以前不知道的东西。卡特兰数的递推公式是F(n)=∑(k=1…n){F(k-1)*F(n-k)}=∑(k=0…n-1){F(k)*F(n-k-1)} 一般性公式为F(n)=C(2n,n)/(n+1)可以描述的问题有 1、n个元素的二叉查找树有多少种。 2、n*n棋盘从左下角走到右上角而不穿过主对角线的走法。 3、2n个人排队买票问题,票价50,n个

2015-10-16 11:48:16 465

原创 组合问题:全组合和C(n,m)

问题: 1.数组a[1~n],生成数组中所有元素的组合。 2.生成C(n,m)组合问题一:全组合思想: 数组长度为4,用4位2进制:0000~1111,二进制位为1表示选取该位元素,0表示不选。 代码://nums数组长度为n,mask为n位二进制掩码,二进制位为0,则选取该对应元素vector<int> getCombByMask(vector<int> nums,int mask,int

2015-09-29 23:35:50 723

原创 全排列问题:序号与排列转换

问题:全排列按字典序排序,每个排列都对应有一个序号。1.根据序号求排列;2.根据排列求序号。思想:n的阶乘的进制思想,从前往后一次是n!, (n-1)!, …, 2!, 1!。代码:1.根据排列求序号//一个排列在字典序全排列中的序号,输入:一个排列,输出:排列的序号int perm2num(vector<int> p){ int n=p.size(); int num=0;

2015-09-29 17:35:54 2184

原创 全排列生成算法

问题:生成1~n的全排列(生成一个数组中所有元素的全排列)。方法一:字典序方法思想:依据字典序顺序,由前一个排列,生成后一个排列。 代码://字典序方法:输入前一个排列,输出后一个排列vector<int> &nextPermutation(vector<int> &p){ unsigned long left,right; left=right=p.size()-1; w

2015-09-29 17:28:49 423

原创 网易163邮箱配置-iOS、OS X邮箱客户端

最近处于找工作阶段,收邮件比较头疼,我用了foxmail邮箱和163邮箱,想用一个客户端收邮件。我个人常用foxmail,但是像应聘360和网易等还是用163的邮箱比较好。本人是轻度强迫症患者:想让自己的MacBook Pro和iPhone 6s的邮件客户端能同时连接上foxmail和163,这样收发邮件就很方便。不想用网易的邮箱大师客户端,还有一个原因是邮箱大师没有mac版。连接foxmail比较

2015-09-26 14:24:40 27809

原创 leetcode 3 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For “

2015-09-22 19:08:43 347

原创 leetcode 152 Maximum Product Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest produ

2015-09-22 18:17:32 361

原创 leetcode 53 Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the

2015-09-22 16:51:17 262

原创 不小于N的素数个数

不小于N的素数个数使用eratosthenes algorithm算法。 算法思想:从2~n遍历,过滤到素数的倍数,没有被过滤的就是素数。//eratosthenes algorithmint countPrimes(int n) { //使用0和1两种状态就OK vector<int> vn(n,1); int count=0; for(int i=2;i<n;

2015-09-18 22:55:13 849

原创 leetcode 220 Contains Duplicate III

Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j is

2015-09-14 19:43:12 317

原创 leetcode 76 Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example, S = “ADOBECODEBANC” T = “ABC” Minimum window is “BANC”.Note:

2015-09-14 19:38:21 342

转载 硬币面值组合问题

问题描述  假设我们有8种不同面值的硬币{1,2,5,10,20,50,100,200},用这些硬币组合够成一个给定的数值n。例如n=200,那么一种可能的组合方式为 200 = 3 * 1 + 1*2 + 1*5 + 2*20 + 1 * 50 + 1 * 100. 问总过有多少种可能的组合方式? (这道题目来自著名编程网站ProjectEuler, 点击这里查看原题目) 类似的题目还有:

2015-09-14 18:03:07 1256

原创 23种设计模式彩图-设计模式之禅

《The Zen of Design Patterns》 —《设计模式之禅》 书中的23种设计模式彩图:

2015-09-12 22:05:33 4971 1

原创 64匹马8个跑道问题

64匹马,8个跑道,假设马发挥稳定且没有体力问题,需要多少场可以决出所有名次(前4名/前8名)。方法一:归并方法,49场1). 把64匹马分成8组,先把每组排个序,共8场比赛。2). 把这8组8匹马两两合并为4组16匹马的有序组,每次合并需要3场比赛。这里就是本题的关键所在:从其中任意选出两组,合并后的前4名肯定在两组的前4名这8匹马里,这8匹比一场就把两组的前4比出来了;对剩下的12马采取同样

2015-08-30 00:40:48 11227 9

转载 25匹马5个跑道问题

问题是这样的:一共有25匹马,有一个赛场,赛场有5个赛道,就是说最多同时可以有5匹马一起比赛。假设每匹马都跑的很稳定,不用任何其他工具,只通过马与马之间的比赛,试问最少 得比多少场才能知道跑得最快的5匹马(或者3匹马)。 注意: "假设每匹马都跑的很稳定" 的意思是在上一场比赛中A马比B马快,则下一场比赛中A马依然比B马快。 稍微想一下,可以采用一种 竞标赛排序(T

2015-08-30 00:23:36 2074 3

转载 桶排序-Bucket Sort

转载:http://hxraid.iteye.com/blog/647759从《基于比较的排序结构总结 》中我们知道:全依赖“比较”操作的排序算法时间复杂度的一个下界O(N*logN)。但确实存在更快的算法。这些算法并不是不用“比较”操作,也不是想办法将比较操作的次数减少到 logN。而是利用对待排数据的某些限定性假设 ,来避免绝大多数的“比较”操作。桶排序就是这样的原理。桶排序的基本思想假设有一组

2015-08-29 13:29:23 475

原创 基数排序-RadixSort

一. 算法描述基数排序(以整形为例),将整形10进制按每位拆分,然后从低位到高位依次比较各个位。主要分为两个过程: (1)分配,先从个位开始,根据位值(0-9)分别放到0~9号桶中(比如53,个位为3,则放入3号桶中) (2)收集,再将放置在0~9号桶中的数据按顺序放到数组中 重复(1)(2)过程,从个位到最高位(比如32位无符号整形最大数4294967296,最高位10位) 以【521 3

2015-08-29 11:40:50 358

原创 冒泡排序-Bubble Sort

算法思想:设数组长度为N。 1.比较相邻的前后二个数据,如果前面数据大于后面的数据,就将两个数据交换。 2.这样对数组的第0个数据到N-1个数据进行一次遍历后,最大的一个数据就“沉”到数组第N-1个位置。 3.N=N-1,如果N不为0就重复前面二步,否则排序完成。代码基本实现:void bubbleSort(vector<int> &nums){ int length=nums.siz

2015-08-28 17:25:00 430

原创 选择排序-SelectionSort

算法思想: 从所有序列中先找到最小的,然后放到第一个位置。之后再看剩余元素中最小的,放到第二个位置……以此类推,就可以完成整个的排序工作了。可以很清楚的发现,选择排序是固定位置,找元素,然后将元素调整到指定位置。代码:class SlectionSort{public: void selectionSort(vector<int> &nums){ int length=n

2015-08-28 17:13:18 417

原创 插入排序-InsertSort

插入排序(Insertion Sort)的基本思想是:每次将一个待排序的记录,按其关键字大小插入到前面已经排好序的子文件中的适当位置,直到全部记录插入完成为止。插入排序步骤: 1.在有序序列中查找插入点 2.从插入点开始向后移动数据(1、2可合并,边查找边移动数据) 3.插入数据插入排序根据查找插入点方法不同分为:直接插入排序和二分插入排序。代码直接插入排序:class InsertSort

2015-08-28 11:25:49 488

原创 leetcode 154 : Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unknown to y

2015-08-26 17:24:37 307

原创 leetcode 153 : Find Minimum 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).Find the minimum element.You may assume no duplicate exists in the array.代码cla

2015-08-26 17:19:26 237

原创 leetcode 81 : Search in Rotated Sorted Array II

Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.代码

2015-08-26 17:04:01 335

原创 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 array return its index

2015-08-26 17:01:14 307

原创 leetcode 240 : Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right. Integers in each co

2015-08-26 16:56:33 274

原创 leetcode 74 : Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of each row is

2015-08-26 16:52:22 305

cos-xml-auth

腾讯云cos签名算法实现及测试demo。 https://qcloud.com/document/product/436/7778

2017-04-27

空空如也

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

TA关注的人

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