Fast I/O 模板

[来源:2017 Multi-University Training Contest - Team 1]

//面包有毒:P

#define BUF_SIZE 100000
//fread -> read
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


for (int Case=1; read(n), !IOerror;Case++){}
原文地址:https://www.cnblogs.com/jszkc/p/7236898.html