zoukankan      html  css  js  c++  java
  • fread 的读入

    碰到HDU 2993这道傻逼题,调了一下午我还一直以为是自己写的有问题,结果竟然卡快读,迫不得已使用了fread...
    比如这种数据
    N M
    x1 x2 ... xn
    应该这样读= =

    namespace fastIO {
        #define BUF_SIZE 100000
        bool IOerror = 0;
        inline char nc() {
            static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
            if(p1==pend){
                p1=buf;
                pend=buf+fread(buf,1,BUF_SIZE,stdin);
                if(pend==p1) {
                    IOerror=1;
                    return -1;
                }
            }
            return *p1++;
        }
        inline bool blank(char ch) {
            return ch==' '||ch=='
    '||ch =='
    '||ch=='	';
        }
        inline void read(int &x) {
            char ch;
            while(blank(ch = nc()));
            if(IOerror) return;
            for(x=ch-'0';(ch=nc())>='0' && ch<='9';x=x*10+ch-'0');
        }
        inline void read(long long int &x) {
            char ch;
            while(blank(ch=nc()));
            if(IOerror) return;
            for(x=ch-'0';(ch=nc())>='0' && ch<='9';x=x*10+ch-'0');
        }
        #undef BUF_SIZE
    };
    
    int main(){
        int N,M;
        while(fastIO::read(N),!fastIO::IOerror){
            fastIO::read(M);
            for(RG i=1;i<=N;++i){
                int x;
                fastIO::read(x);
            }
        }
        return;
    }
    
  • 相关阅读:
    轻松完成mysql4.1与mysql4.0数据库转换备份
    MYSQL数据迁徙tips,ORA00907: missing right parenthesis
    viking病毒再次感染公司LAN
    [恢]hdu 2032
    [恢]hdu 2042
    [恢]hdu 2033
    [恢]hdu 2039
    [恢]hdu 2029
    [恢]hdu 2010
    [恢]hdu 2016
  • 原文地址:https://www.cnblogs.com/AEMShana/p/13388309.html
Copyright © 2011-2022 走看看