【模板】快速读入

版权声明:欢迎转载(请附带原链接)ヾ(๑╹◡╹)ノ" https://blog.csdn.net/corsica6/article/details/83026997

快读模板

struct FastIO {
    static const int S=1e6;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int gc(){
        static char buf[S];
        static int len=0,pos=0;
        if(pos==len)
            pos=0,len=fread(buf,1,S,stdin);
        if(pos==len) return 0;
        return buf[pos++];
    }
    
    inline void rd(int &x) {
        int c=gc();x=0;
        for(;c<=32;c=gc());
        for (;isdigit(c);c=gc()) x=x*10+c-'0';
    }
    
    inline void wchar(int x)
    {
        if (wpos==S) 
		  fwrite(wbuf,1,S,stdout),wpos=0;
        wbuf[wpos++]=x;
    }
    
    inline void ot(int x,char cp)
    {
        static char s[30];
        int nm=0;
        for(;x || !nm;) s[nm++]='0'+x%10,x/=10;
        for(--nm;~nm;--nm) wchar(s[nm]);
        wchar(cp);
    }
    
    ~FastIO()
    {if (wpos) fwrite(wbuf,1,wpos,stdout),wpos=0;}
}io;

猜你喜欢

转载自blog.csdn.net/corsica6/article/details/83026997
今日推荐