• 算法笔记--快读(输入外挂)模板


    inline int read(){  
       int s=0,w=1;  
       char ch=getchar();  
       while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}  
       while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();  
       return s*w;  
    } 
    void read(int &x){
        char ch = getchar();x = 0;
        for (; ch < '0' || ch > '9'; ch = getchar());
        for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    }
    struct FastIO {
        static const int S = 4e6;
        int wpos;
        char wbuf[S];
        FastIO() : wpos(0) {}
        inline int xchar() {
            static char buf[S];
            static int len = 0, pos = 0;
            if (pos == len)
                pos = 0, len = fread(buf, 1, S, stdin);
            if (pos == len) exit(0);
            return buf[pos++];
        }
        inline int xuint() {
            int c = xchar(), x = 0;
            while (c <= 32) c = xchar();
            for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
            return x;
        }
        inline int xint()
        {
            int s = 1, c = xchar(), x = 0;
            while (c <= 32) c = xchar();
            if (c == '-') s = -1, c = xchar();
            for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
            return x * s;
        }
        inline void xstring(char *s)
        {
            int c = xchar();
            while (c <= 32) c = xchar();
            for (; c > 32; c = xchar()) * s++ = c;
            *s = 0;
        }
        inline void wchar(int x)
        {
            if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
            wbuf[wpos++] = x;
        }
        inline void wint(int x)
        {
            if (x < 0) wchar('-'), x = -x;
            char s[24];
            int n = 0;
            while (x || !n) s[n++] = '0' + x % 10, x /= 10;
            while (n--) wchar(s[n]);
            wchar('
    ');
        }
        inline void wstring(const char *s)
        {
            while (*s) wchar(*s++);
        }
        ~FastIO()
        {
            if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
        }
    } io;

    带多组的读入优化

    const int BUF = 25000000;
    char Buf[BUF],*buf=Buf;
    inline void read(int &a)
    {
        for(a=0;*buf<48;buf++);
        while(*buf>47) a=a*10+*buf++-48;
    }
    
    int tot = fread(Buf, 1, BUF, stdin);
    while(true) {
            if(buf-Buf+1 >= tot) break;
    }
  • 相关阅读:
    java使用http获取 GET请求接口数据代码
    sql语句和造数据脚本
    .NET创建委托可大幅度提高反射调用的性能
    typescript 单例模式
    文字全方位描边效果
    【动植物研究动态】20220605文献解读
    vue.use干了什么,在什么时候用 mn
    error: expected ‘)’ before ‘PRIx64’
    sqlserver获取所有表的字段说明
    PCB+SMT线上报价系统,数字化建设如何获取现金流?
  • 原文地址:https://www.cnblogs.com/widsom/p/7622165.html
Copyright © 2020-2023  润新知