读入/输出模板

就是稍微码下

①读入优化

inline int read() {char c=GT();int u=1,o=0;
    for(;!isdigit(c);c=GT()) if(c=='-')u=-1;
    for(;isdigit(c);o=(o<<3)+(o<<1)+c-'0',c=GT());return o*u;
}

②读入优化

inline int read(int &o) {o=0;char c=GT();int u=1;
    for(;!isdigit(c);c=GT()) if(c=='-')u=-1;
    for(;isdigit(c);o=(o<<3)+(o<<1)+c-'0',c=GT()); o*=u;
}

③输出优化

char pbuf[100000],*pp=pbuf;
void push(const char c) {
    if(pp-pbuf==100000) fwrite(pbuf,1,100000,stdout),pp=pbuf;
    *pp++=c;
}
void write(int x) {
    static int sta[35];
    int top=0;
    do{sta[top++]=x%10,x/=10;}while(x);
    while(top) push(sta[--top]+'0');
}

 

④输出优化附录(代码末)

fwrite(pbuf,1,pp-pbuf,stdout);
posted @ 2018-08-20 14:13  六夜  阅读(109)  评论(0编辑  收藏  举报
博客园 首页 私信博主 显示目录 隐藏目录 管理 动画