zoukankan      html  css  js  c++  java
  • 读入优化!

    两种,不知道两种谁快。。。

    inline char nc() {
        static char buf[100000], *p1 = buf, *p2 = buf;
        return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
    }
    inline int _read() {
        char ch = nc(); int sum = 0;
        while (!(ch >= '0'&&ch <= '9'))ch = nc();
        while (ch >= '0'&&ch <= '9')sum = sum * 10 + ch - 48, ch = nc();
        return sum;
    }
    View Code
    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' )
                ;
        }
    
    
    #undef BUF_SIZE
    };
    using namespace fastIO;
    View Code
  • 相关阅读:
    Dangling Javadoc comment
    IntelliJ IDEA :Error(1, 1) java 非法字符 'ufeff'
    什么是webhook
    智能DNS
    filebeat 乱码
    windows,交换机syslog收集
    Rsyslog
    ntp
    centos7 -lvm卷组
    nginx安装
  • 原文地址:https://www.cnblogs.com/WWkkk/p/9470619.html
Copyright © 2011-2022 走看看