跳到正文

个人记录

Marser的模板大全(更新中)

Marser约 2 分钟
原文
文章信息与版本

文章信息

发布
2020年4月24日
收录
2025年12月12日
更新
2026年11月6日
篇幅
约 2 分钟

版本

  1. v1当前

输入输出优化

C++
namespace IO{
    char buf[1<<15],*S,*T;
    inline char gc(){
        if(S==T){
            T=(S=buf)+fread(buf,1,1<<15,stdin);
            if(S==T)return EOF;
        }
		return *S++;
    }
    inline int read(){
        reg int x;reg char c;
        for(;(c=gc())<'0'||c>'9';);
        for(x=c^'0';(c=gc())>='0'&&c<='9';x=x*10+c-'0');
        return x;
    }
    const int _outlim=1<<20;
    char outbuf[_outlim+5];int cnt;
    inline void pc(char c){
        outbuf[cnt++]=c;
        if(cnt==_outlim)
            fwrite(outbuf,1,cnt,stdout),cnt=0;
    }
    inline void write(int x){
        if(x>9)write(x/10);pc(x%10^'0');
    }
    inline void end(){
        if(cnt)fwrite(outbuf,1,cnt,stdout);
		fclose(stdin);fclose(stdout);
    }
}
原文
存档评论2 条抓取于