zoukankan      html  css  js  c++  java
  • 输入输出挂

    namespace IO {
        const int MT = 10 * 1024 * 1024;  /// 10MB 请注意输入数据的大小!!!
        char IO_BUF[MT];
        int IO_PTR, IO_SZ;
        /// 要记得把这一行添加到main函数第一行!!!
        void begin() {
            IO_PTR = 0;
            IO_SZ = fread (IO_BUF, 1, MT, stdin);
        }
        template<typename T>
        inline bool scan_d (T & t) {
            while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] != '-' && (IO_BUF[IO_PTR] < '0' || IO_BUF[IO_PTR] > '9'))
                IO_PTR ++;
            if (IO_PTR >= IO_SZ) return false;
            bool sgn = false;
            if (IO_BUF[IO_PTR] == '-') sgn = true, IO_PTR ++;
            for (t = 0; IO_PTR < IO_SZ && '0' <= IO_BUF[IO_PTR] && IO_BUF[IO_PTR] <= '9'; IO_PTR ++)
                t = t * 10 + IO_BUF[IO_PTR] - '0';
            if (sgn) t = -t;
            return true;
        }
        inline bool scan_s (char s[]) {
            while (IO_PTR < IO_SZ && (IO_BUF[IO_PTR] == ' ' || IO_BUF[IO_PTR] == '
    ') ) IO_PTR ++;
            if (IO_PTR >= IO_SZ) return false;
            int len = 0;
            while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] != ' ' && IO_BUF[IO_PTR] != '
    ')
                s[len ++] = IO_BUF[IO_PTR], IO_PTR ++;
            s[len] = '';
            return true;
        }
        template<typename T>
        void print(T x) {
            static char s[33], *s1; s1 = s;
            if (!x) *s1++ = '0';
            if (x < 0) putchar('-'), x = -x;
            while(x) *s1++ = (x % 10 + '0'), x /= 10;
            while(s1-- != s) putchar(*s1);
        }
        template<typename T>
        void println(T x) {
            print(x); putchar('
    ');
        }
    };

    用法: 

    在main函数内加上  IO::begin();

    读入:

       IO::scan_d(数字的变量名)

       IO::scan_s(字符串之类的变量名)
    输出:
            IO::println(输出的变量名字);
    int  main()
    {
        IO::begin();
        while(IO::scan_d(n))
        {
            for(int i=1;i<=n;i++)
                IO::scan_d(a[i].l);
            for(int i=1;i<=n;i++)
                IO::scan_d(a[i].r),a[i].id=i;
            IO::println(dfs(1,n));
        }
    }
  • 相关阅读:
    E寻宝(贪心)
    千万别点进来,点进来你就哭了(最短路,dijkstra)
    H小明买年糕(前缀和+二分)
    Charles破解
    Jmeter安装插件
    appium环境搭建
    SourceTree安装和教程
    Appium-desktopAppium-desktop 安装与入门使用
    appium终端安装
    Seleinum_CSS定位方式
  • 原文地址:https://www.cnblogs.com/stepping/p/7679542.html
Copyright © 2011-2022 走看看