fread优化读入

inline char nc()
{
    static const int BS = 1 << 22;
    static unsigned char buf[BS],*st,*ed;
    if(st == ed) ed = buf + fread(st=buf,1,BS,stdin);
    return st == ed ? EOF : *st++;
}
//#define nc getchar
inline int read()
{
    char ch;
    int res = 0; bool flag = 0;
    while (!isdigit(ch = nc()));
    while (ch >= '0' and ch <= '9')
    {
        res = (res << 1) + (res << 3) + (ch - '0');
        ch = nc();
    }
    return res;
}

 

卡常

posted @ 2018-05-22 22:08  zZhBr  阅读(404)  评论(0编辑  收藏  举报