常用工具整理

 

  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;
    }

 



 

 

posted @ 2018-01-26 13:16  懿路智行  阅读(97)  评论(0编辑  收藏  举报