zoukankan      html  css  js  c++  java
  • 方便人类——信息学训练专用库

    /*
        Author:597
        Description:
        This is a Header File for coding.
        It has many function which can make us coding easily or running quickly.
    */
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstdlib>
    #include <algorithm>
    using namespace std;
    //File IO
    #define I_O(x) freopen(""#x".in","r",stdin);freopen(""#x".out","w",stdout)
    //for Pascal党&码速 
    #define forp(i,a,b) for(i=a;i<=b;i++)
    #define form(i,a,b) for(i=a;i>=b;i--)
    #define until(x) while (!(x))
    //for "memset"
    #define INF 2139062143
    #define NINF -2139062144
    //for 读入优化 
    #define IN(x,a,b) (a<=x && x<=b)
    template <typename T>
        inline void input(T& x)//专为读整数设计 
        {
            char ch=getchar();
            while (!(IN(ch,'0','9')||ch=='-'))
                ch=getchar();
            if (ch!='-')
            {
                x=0;
                do
                {
                    x=x*10+ch-48;
                    ch=getchar();
                }
                while (IN(ch,'0','9'));
            }
            else
            {
                ch=getchar();
                x=0;
                do
                {
                    x=x*10+ch-48;
                    ch=getchar();
                }
                while (IN(ch,'0','9'));
                x=-x;
            }
        }
    inline int get_int()//专为读int设计
    {
        char ch=getchar();
        int x=0;
        while (!(IN(ch,'0','9')||ch=='-'))
            ch=getchar();
        if (ch!='-')
        {
            do
            {
                x=x*10+ch-48;
                ch=getchar();
            }
            while (IN(ch,'0','9'));
        }
        else
        {
            ch=getchar();
            do
            {
                x=x*10+ch-48;
                ch=getchar();
            }
            while (IN(ch,'0','9'));
            x=-x;
        }
        return x;
    }
    //for math
    template <typename T>
        inline T sqr(T x){return x*x;}
    template <typename T>
        inline T pow(T x,T y)
        {
            T tmp=x,ret=1;
            while (y)
            {
                if (y&1)
                    ret*=tmp;
                y>>=1;
                tmp*=tmp;   
            }
            return ret;
        }
    //for random(including <cstdlib> and <ctime>)
    #define randomize srand(time(0))
    #define random(l,r) (l+rand()%(r-l+1))
    //for string
    #include <string>
    using namespace std;
    inline void input(string& s)//读字符串 
    {
        char ch=getchar();
        while (!IN(ch,33,126))
            ch=getchar();
        s="";
        do
        {
            s+=ch;
            ch=getchar();
        }
        while (IN(ch,33,126));
    }
    inline void input_line(string& s)
    {
        char ch=getchar();
        while (!IN(ch,32,126))
            ch=getchar();
        s="";
        do
        {
            s+=ch;
            ch=getchar();
        }
        while (IN(ch,32,126));
    }
    inline void output(string& s)//写字符串(没帮你换行,若是要换行打上putchar('
    ');) 
    {
        int i;
        for (i=0;s[i]!='';i++)
            putchar(s[i]);
    }
  • 相关阅读:
    socket server的N种并发模型
    进程、线程以及Goroutine的区别
    分布式从ACID、CAP、BASE的理论推进
    epoll的理论与IO阻塞机制
    golang面试题知识点总结
    golang中如何进行项目模块及依赖管理
    面对golang中defer,要注意什么?
    Kaggle 学习之旅
    推荐在线学习读书网站
    k8s 的 dashboard 的实践
  • 原文地址:https://www.cnblogs.com/jz-597/p/11145209.html
Copyright © 2011-2022 走看看