输入挂

输入挂,原理是把文件里面的东西用fread一次性读到内存。
使用时必须 #include “cctype”, 先调用 IO:init(); 然后全部用 IO:readint() 读入数据;

namespace IO {
    const static int maxn = 200 << 20;
    static char buf[maxn], *pbuf = buf, *End;
    void init() {
        int c = fread(buf, 1, maxn, stdin);
        End = buf + c;
    }
    int &readint() {
        static int ans;
        ans = 0;
        while (pbuf != End && !isdigit(*pbuf)) pbuf ++;
        while (pbuf != End && isdigit(*pbuf)) {
            ans = ans * 10 + *pbuf - '0';
            pbuf ++;
        }
        return ans;
    }
}

你可能感兴趣的:(输入挂)