- 博客(162)
- 资源 (8)
- 收藏
- 关注
原创 网易smtp 出现 554 DT:SPM,原因在这里
解决方案:珍爱生命,远离网易邮箱!!!珍爱生命,远离网易邮箱!!!珍爱生命,远离网易邮箱!!!经过一天的尝试,我明白了,网易的想法就是:压根就不想给你们这群不付钱的穷逼用,用尼玛啊,赶紧滚!可怜不知情的同学们,以为自己哪里写得不对,找来找去,白白浪费生命从商业角度讲,网易这样做倒也很正常,smtp这些东西浪费带宽,却不提高广告点击率,作为全国最大的邮箱服务商,面对的是全国的...
2019-11-25 17:46:16 9918 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 208
原创 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 153355 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 4296
原创 可重入与线程安全
网上很多相关的分析文章。我感觉这是两个不同的问题,可重入问题是在signal handler里发生的,是由于使用全局数据和静态数据引起的,只要修改静态数据或全局数据就不是可重入的,通过避免这种问题(即尽量不使用全局数据)解决,跟线程无关。线程安全问题是在线程间发生的访问共享资源引起的,通过避免同时访问资源(加各种锁)解决。很多人分析的线程安全的是否是可重入的,可重入的是否是线程安全的,我感觉可
2015-05-24 06:34:05 357
原创 老鼠喝毒水问题
问题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 2822
原创 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 336
原创 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 335
原创 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 348
原创 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 432
原创 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 306
原创 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 370
原创 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 292
原创 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 328
原创 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 2282
原创 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 2021
原创 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 1315
原创 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 323
原创 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 324
原创 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 347
原创 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 337
原创 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 351
原创 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 394
原创 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 318
原创 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 479
原创 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 357
原创 1064. Complete Binary Search Tree
问如何简便地用一个有序序列生成一个平衡二叉树1.给定一个数字n,能否生成一个n个节点的完全二叉树?——能2.这个生成的完全二叉树,能否以中序遍历?——能,它只是一个使用数字控制结点数目的普通二叉树,与一般二叉树并无不同3.平衡二叉树与有序序列有何共同之处——BST的中序遍历也是一个有序序列#include#include#include#includeusing
2014-07-18 22:24:18 359
原创 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 330
原创 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 294
原创 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 429
原创 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 305
Learn Windows PowerShell 3 in a Month of Lunches, 2nd Edition.pdf
2017-01-05
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人