常用工具整理

  1. 宏定义
    #define ll long long
    #define db double
    #define rep(i,j,k) for(int i = (j), i <= (k), i++)
    #define Rrep(i,j,k) for(int i = (j), i >= (k), i--)
    #define file(s)     freopen(#s".in","r",stdin), freopen(#s".out","w",stdout)
    const int inf = 0x3f3f3f3f;
  2. 模板函数
    template<class T> inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
    template<class T> inline void read(T& ans){
        int f = 1; char c = getchar(); ans=0;
        while(c < '0' || c > '9')
            if(c == '-') f = -1, c = getchar();
        while('0' <= c && c <= '9')
            ans = (ans << 1) + (ans << 3) + (c ^ 48), c = getchar();
        ans = ans * f;
    }



原文地址:https://www.cnblogs.com/Eroad/p/9373476.html