zoukankan      html  css  js  c++  java
  • 大佬的几行fastIO

    namespace io {
      const int SIZE = 1e6;
      char buff[SIZE];
      char *l = buff, *r = buff;
      void init() {
        l = buff;
        r = l + fread(buff, 1, SIZE, stdin);
      }
      char gc() {
        if (l == r) init();
        if(l==r)return EOF;
          return *(l++);
      }
      void read(int &x) {
        x = 0;
        char ch = gc();
        while(!isdigit(ch)) ch = gc();
        while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
      }
    }using io::read;
    #include<iostream>
    #include<cctype>
    using namespace std;
    using std::cin;
    using std::cout;
    using std::endl;
    namespace IN {
        const int MAX_INPUT = 1000000;
        #define getc() (p1 == p2 && (p2 = (p1 = buf) + inbuf -> sgetn(buf, MAX_INPUT), p1 == p2) ? EOF : *p1++)
        char buf[MAX_INPUT], *p1, *p2;
        template <typename T> inline bool redi(T &x) {
            static std::streambuf *inbuf = cin.rdbuf();
            x = 0;
            register int f = 0, flag = false;
            register char ch = getc();
            while (!std::isdigit(ch)) {
                if (ch == '-') f = 1;
            ch = getc();
            }
            if (std::isdigit(ch)) x = x * 10 + ch - '0', ch = getc(),flag = true;
            while (std::isdigit(ch)) {
                x = x * 10 + ch - 48;
                ch = getc();
            }
            x = f ? -x : x ;
            return flag;
        }
        template <typename T,typename ...Args> inline bool redi(T& a,Args& ...args) {
           return redi(a) && redi(args...);
        }
        #undef getc
    }
    
    namespace OUT {
        template <typename T> inline void put(T x) {
            static std::streambuf *outbuf = cout.rdbuf();
            static char stack[21];
            static int top = 0;
            if (x < 0) {
                outbuf -> sputc('-');
                x=-x;
            }
            if (!x) {
                outbuf -> sputc('0');
                outbuf -> sputc('
    ');
                return;
            }
            while (x) {
                stack[++top] = x % 10 + '0';
                x /= 10;
            }
            while (top) {
                outbuf -> sputc(stack[top]);
                -- top;
            }
            outbuf -> sputc('
    ');
        }
        inline void putc (const char ch) {
            static std::streambuf *outbuf = cout.rdbuf();
            outbuf -> sputc(ch);
        }
        template <typename T> inline void put(const char ch,T x)
        {
            static std::streambuf *outbuf = cout.rdbuf();
            static char stack[21];
            static int top = 0;
            if (x < 0) {
                outbuf -> sputc('-');
                x=-x;
            }
            if (!x) {
                outbuf -> sputc('0');
                outbuf -> sputc(ch);
                return;
            }
            while (x) {
                stack[++top] = x % 10 + '0';
                x /= 10;
            }
            while (top) {
                outbuf -> sputc(stack[top]);
                --top;
            }
            outbuf -> sputc(ch);
        }
        template<typename T,typename ...Args> inline void put(T a,Args ...args) {
            put(a);put(args...);
        }
        template<typename T,typename ...Args> inline void put(const char ch,T a,Args ...args) {
            put(ch,a);put(ch,args...);
        }
    }
    using IN::redi;
    using OUT::put;
    using OUT::putc;
    int main(int argc, char const *argv[])
    {
        freopen("testdata.in","r",stdin);
        freopen("testdata.out","w",stdout);
        std::ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int a,b;
        redi(a,b);
        put(' ',a,b);
        putc('
    ');
        put('
    ',a,b,a+b,a*b);
        fclose(stdin);fclose(stdout);
        return 0;
    }
  • 相关阅读:
    App.config使用ASP.NET Web Project的Transformation模式编译方式
    简易扩展Visual Studio UnitTesting支持TestMethodCase
    Microsoft Unity ---- 系列文章
    Reflector 7.0.0.420 注册破解版
    在Vue前端界面中,几种数据表格的展示处理,以及表格编辑录入处理操作。
    基于Vue的工作流项目模块中,使用动态组件的方式统一呈现不同表单数据的处理方式
    在Vue前端项目中,附件展示的自定义组件开发
    在Vue&Element前端项目中,对于字典列表的显示处理
    kestrel对接elasticsearch踩坑记
    华为智慧安平解决方案——安防视频监控是核心
  • 原文地址:https://www.cnblogs.com/Yuhuger/p/9330626.html
Copyright © 2011-2022 走看看