自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

null

null

  • 博客(162)
  • 资源 (8)
  • 收藏
  • 关注

原创 CORS跨域-简要原理

简单说明跨域原理

2022-12-13 10:53:49 289

原创 网易smtp 出现 554 DT:SPM,原因在这里

解决方案:珍爱生命,远离网易邮箱!!!珍爱生命,远离网易邮箱!!!珍爱生命,远离网易邮箱!!!经过一天的尝试,我明白了,网易的想法就是:压根就不想给你们这群不付钱的穷逼用,用尼玛啊,赶紧滚!可怜不知情的同学们,以为自己哪里写得不对,找来找去,白白浪费生命从商业角度讲,网易这样做倒也很正常,smtp这些东西浪费带宽,却不提高广告点击率,作为全国最大的邮箱服务商,面对的是全国的...

2019-11-25 17:46:16 9835 11

原创 一些问题

create-react-app使用cnpm start发生webpack版本问题。解决方法:使用32位版本的nodejsubuntu下使用vsftpd无法登陆,原来/etc/ftpusers 是黑名单,root用户也被拒绝了。https://www.jianshu.com/p/1f6a4f2de7b6...

2019-04-02 16:37:10 190

原创 post使用form-data和x-www-form-urlencoded的本质区别

一是数据包格式的区别,二是数据包中非ANSCII字符怎么编码,是百分号转码发送还是直接发送一、application/x-www-form-urlencoded1、它是post的默认格式,使用js中URLencode转码方法。包括将name、value中的空格替换为加号;将非ascii字符做百分号编码;将input的name、value用‘=’连接,不同的input之间用‘&’连接...

2019-01-10 14:53:33 152811 11

原创 socket write read 阻塞 非阻塞

Linux调用read(int fd,char* buf,size_t len)、write(int fd,char* buf,size_t len)时,不管是作用于一个普通文件、管道或者socket,都是在用户的buf[ len ]与内核所控制的内存间来回拷贝,一个最基本的原因是buf这个地址所对应的硬件地址可能换出到磁盘了,当然还有其它原因。Linux经过内核内存来中转。在阻塞(默认)时:

2015-07-09 06:55:44 4230

原创 快速排序 冒泡排序 归并排序 堆排序 的主要代码

快速排序 冒泡排序 归并排序 堆排序

2015-06-22 09:12:27 454

原创 可重入与线程安全

网上很多相关的分析文章。我感觉这是两个不同的问题,可重入问题是在signal handler里发生的,是由于使用全局数据和静态数据引起的,只要修改静态数据或全局数据就不是可重入的,通过避免这种问题(即尽量不使用全局数据)解决,跟线程无关。线程安全问题是在线程间发生的访问共享资源引起的,通过避免同时访问资源(加各种锁)解决。很多人分析的线程安全的是否是可重入的,可重入的是否是线程安全的,我感觉可

2015-05-24 06:34:05 344

原创 老鼠喝毒水问题

问题1:有1000瓶外表一样的水,其中一瓶里面有毒药,老鼠喝下毒药1天内会死,求怎样在一天内用最少的老鼠数量判断哪瓶水有毒。答:10只老鼠。用一天的时间就是说只做一轮实验,瓶子用编号0~999(用10位2进制数,即0000000000,0000000001,0000000010……,这样瓶子的编号从右往左分别为0号位、1号位……一共10个位),给老鼠编号0~9,i号老鼠喝下所有i号位为0的瓶子

2015-04-26 08:45:13 2763

原创 Longest Substring Without Repeating Characters

int lengthOfLongestSubstring(string s){ const int N=256;  vectorlastpos(N),met(N);  int start=0,cur=start;  int len=0,maxlen=0;  for(; cur<s.size();++cur)    {      int ch=s[cur];   

2015-04-17 19:56:59 323

原创 2 Add Two Numbers

ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) {  ListNode*root=new ListNode(0), *pre=root; int carry=0; while(l1!=NULL || l2!=NULL) { if(l1!=NULL) {carry+= l1->val; l1= l1->next;} if(l2!=NULL) {

2015-04-17 15:50:15 322

原创 LeetCode1 Two Sum

unordered_mapindex; for(int i=0;i<numbers.size();++i) { auto it=index.find(target-numbers[i]); if(it==index.end()) index[numbers[i]]=i; else { int tmp=it->second; retur

2015-04-17 15:26:45 334

原创 1087. All Roads Lead to Rome (30)

#include#include#include#include#includeusing namespace std;const int N=300;int pos;string name[300];int s2i(string s){ static unordered_mapnth; auto it=nth.find(s); if(it!=nth.end())

2015-03-18 13:38:14 410

原创 1086. Tree Traversals Again

这个题让我想起“递归改写成循环”这个问题,所有递归都可以用步骤标记的方式改写成循环,尤其是树的非递归式遍历挺有意思#include#includeusing namespace std;struct node{int lch,rch;};node v[60];int pop[60],id[60];void post(int k){ if(!k)return ; static

2015-03-18 11:30:21 286

原创 1085. Perfect Sequence (25)

又一个线性扫描数组的例子#include#include#includeusing namespace std;int main(){ long long n,p;cin>>n>>p; vectorv(n); for(auto&x:v)cin>>x; sort(v.begin(),v.end()); long long pos=0,maxlen=0; for(l

2015-03-18 10:57:24 359

原创 1078. Hashing

#include#includeusing namespace std;vectorused(10003);bool isprime(int k){ if(k==1)return false; if(k==2||k==3)return true; for(int i=2;i*i<=k;++i) if(k%i==0)return false; return true;

2015-03-17 23:57:10 285

原创 lower_bound与upper_bound

int lowerbound(int l,int r,int target){ while(l<=r){ int mid=(l+r)>>1; if(val[mid]>=target)r=mid-1; else l=mid+1; } return l;}int upperbound(int l,int r,int target){ while(l<=r){

2015-03-16 09:14:53 293

原创 8-05. 银行排队问题之“多队列多窗口”版

可能有些条件没说明白吧,有一个case没过,不过思路差不多就是这样,到来时把该离队的人都强制离队,此时有不满员的队伍就排队,否则队伍全满,找队头最先离开的那个队伍,强制其离队#include#include#includeusing namespace std;const int N=10004,K=1003;int come[N],cost[N],serve[N],n,k,m,le

2015-03-09 11:50:03 2258

原创 8-04. 打印学生选课清单

#include#include#include#includeusing namespace std;char name[5];int f(char*p){return (p[0]-'A')*6760+(p[1]-'A')*260+(p[2]-'A')*10+p[3]-'0';}unordered_multimapke;int main(){ int n,k;scanf("

2015-03-06 13:45:10 1997

原创 PAT5-08. 迷你搜索引擎

#include#include#include#include#include#include#includeusing namespace std;string line[10000];unordered_map >infile;string filename[100];unordered_map >in_line;void readfile(int fileth){

2015-02-27 18:27:52 1267

原创 pat4-06

最后一个case没过,真奇怪#include#include#includeusing namespace std;typedef vector::iterator itr;bool isbst(itr beg,itr end){ if(end-beg<=2)return true; itr mid=find_if(beg+1,end,[&](int x)->bool{ret

2015-02-26 00:53:37 312

原创 pat3-05

#include#includeusing namespace std;const int n=9999999;int val[n];int main(){ int nth,cnt=0; scanf("%d",&nth); while(scanf("%d",&val[cnt]),val[cnt]>=0) ++cnt; if(nth>cnt) printf("

2015-02-25 00:17:08 316

原创 pat2-13

#include#includeusing namespace std;int main(){ int n;scanf("%d",&n); int nth=(2*n-1)/2; vectora(n),b(n); for(auto &x:a)scanf("%d",&x); for(auto &x:b)scanf("%d",&x); int i=0,j=0; for(

2015-02-24 23:10:47 340

原创 pat2-09

#include#includeusing namespace std;int main(){  int n;cin>>n;  vectorbox(n,100);  int used=0;  while(n--){    int weight;cin>>weight;    auto it=find_if(box.begin(),box.end(),[&](in

2015-02-24 20:43:17 325

原创 pat2-06

以为是考察大数加法,用大数加法试了一下,超时了,才发现这样是绕弯路,得抄近路才行大数加法版本:#include#includeusing namespace std;typedef list num;num operator+(num a,num b){ // plus b to a if(a.size()<b.size()) a.swap(b); a.push_fr

2015-02-24 10:49:29 342

原创 大小端

一个数据在内存中可能占了不知一个字节,比如大小端就是一个

2014-08-24 15:19:02 321

原创 红黑树简明图解

一、红黑树1、红黑树为一颗erhc

2014-08-18 14:19:39 685

原创 1005Number Sequence

考察鸽巢原理的应用,数字的取值有k种可能的话,这样的数字取n位组成的n位序列有k^n中可能的排列,任取n+k^n位数字组成一个序列,里面有k^n+1个n位排列,其中一定有重复的。好比有10种颜色的玻璃球,放在11个盒子里,必定有两个球的颜色一样。这里取值范围是0~6共7个,在f的序列中任取两个数的排列有49种(带入公式得51=2+7^2)那么在f[51]的时候必定已经有了循环。因为51个数字需

2014-07-21 15:10:24 379

原创 1004Let the Balloon Rise

#include#include#include#includeusing namespace std;struct node{ string st;int cnt; node(string s,int k=1):st(s),cnt(k){} node(){} bool operator<(const node&x)const{return cnt<x.

2014-07-21 12:14:02 306

原创 1003

#include#include#includeusing namespace std;int main(){    int n;cin>>n;    for(int i=1;i    {        if(i!=1)cout        printf("Case %d:\n",i);        int cnt;cin>>cnt;     

2014-07-20 21:59:30 454

原创 A + B Problem II

两个正的大数相加,HDOJ的每个输出

2014-07-20 20:33:25 297

原创 1033. To Fill or Not to Fill

看当前站可达范围内的加油站,加足够的油到第一个更便宜的站,或者加满油到紧邻的下一个站#include#includeusing namespace std;int cmax,dist,davg,n;double cost,leftoil,maxlen;struct node{int d; double p; node(double a,int b):p(a),d(b){} b

2014-07-20 17:10:58 344

原创 1049. Counting Ones

我实在编程之美上看的答案,看完后感觉mingmingshi

2014-07-19 11:08:36 371

原创 1064. Complete Binary Search Tree

问如何简便地用一个有序序列生成一个平衡二叉树1.给定一个数字n,能否生成一个n个节点的完全二叉树?——能2.这个生成的完全二叉树,能否以中序遍历?——能,它只是一个使用数字控制结点数目的普通二叉树,与一般二叉树并无不同3.平衡二叉树与有序序列有何共同之处——BST的中序遍历也是一个有序序列#include#include#include#includeusing

2014-07-18 22:24:18 350

原创 1066. Root of AVL Tree

#include#includeusing namespace std;struct node{ node*lch,*rch; int key; node(int x):key(x){lch=rch=nullptr;}};using ptr=node*;int deep(ptr p){ if(!p)return 0; return max(d

2014-07-17 20:14:45 316

原创 二叉平衡树AVL插入删除操作的实现

这里有左旋,右旋,左右旋,右左xuanzh

2014-07-17 15:08:02 553

原创 二叉排序树插入删除的实现

二叉排序树的函数只有三个,插入,查找,删除

2014-07-17 09:26:52 398

原创 线性时间素数筛

普通的素数筛原理就是:所有素数的倍数(2倍以上)为

2014-07-16 18:54:56 465

原创 1051. Pop Sequence

保持当前遇到的最大值,小于此最大值的最小值,小于等于此最大值的数字个数,当出现一个新的最大值,其右侧(即随后出栈的)比它小的数字是降序的,总个数不能超出容量,复杂度O(n)#include#includeusing namespace std;int m,n,k,val[2222];int main(){ cin>>m>>n>>k; while(k--){ int mm

2014-07-15 20:13:27 286

原创 1050. String Subtraction

#include#include#includeusing namespace std;int main(){ string st,s; getline(cin,st); getline(cin,s); vectorhas(300,false); for(char c:s)has[c]=true; for(char c:st)if(!has

2014-07-14 16:22:03 418

原创 1065. A+B and C (64bit)

检测int加法溢出用(a>0&&b>0&&b>INT_MAX-a) ||(along long范围是[-2^63, 2^63),但这里的范围是[-2^63, 2^63],如果对于a,b,c分别为2^63 ,0,2^63的情况,long long 根本就不能存这种数,所以用long long 来做这个题是不对的,必须自己做一个大整数的加减法或用java等的大整数功能

2014-07-14 16:11:56 295

ffmpeg-win64-shared&static;.zip

ffmpeg的x64可执行文件,包括static版本和shared版本

2019-09-29

Learn Windows PowerShell 3 in a Month of Lunches, 2nd Edition.pdf

Learn Windows PowerShell 3 in a Month of Lunches

2017-01-05

MinGW5.1.6_X86.zip

x86下的MinGW,全套工具链,省得到处找了

2016-06-16

emacs_23.1.0.0

windows X64下emacs,编译器还是emacs好用

2015-05-04

redis-2.8.19源码

redis工程源码,在src文件夹里,研究源码的童鞋可以看看

2015-05-04

mingw gcc/g++_for_windowsX64

X64下mingw,g++版本4.9,支持c++11、c++14

2015-04-17

mingw_5.0.2.exe

mingw,window下的coding工具

2014-08-16

Linux内核设计与实现(LKD)_中文_第三版

linux内核入门书籍,《深入了解Linux内核》的导论,适合菜鸟.

2014-08-16

空空如也

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

TA关注的人

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