fread快读+fwrite快速输出

定义数组

char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;

读入

#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*f;
}

输出

void print(long long x) {
    if(x>9) print(x/10);
    *O++=x%10+'0';
}
fwrite(obuf,O-obuf,1,stdout);

还是很快的

posted @ 2018-11-05 09:20  SWHsz  阅读(5819)  评论(1编辑  收藏  举报