个人用 C++ 模板

· · 个人记录

空模板:

#include<bits/stdc++.h>
#define LoveFurina ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F(x, l, r) for(int x = l; x <= r; ++x)
#define B(x, r, l) for(int x = r; x >= l; --x)
#define pii pair<int, int>
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
using namespace std;

//const int N = ;



signed main() {
    LoveFurina;



return 0;
}

// 生命如同戏剧,你永远预料不到转折出现在哪一篇章。
// 世间的奇遇之所以存在,就是为了给世人带来转机。

取模模板:

struct Int {
    int val;
    Int(int x = 0) : val((x % mod + mod) % mod) {}
    inline Int operator + (const Int &rhs) const {
        return (1ll * val + rhs.val) % mod;
    }
    inline Int operator - (const Int &rhs) const {
        return (1ll * val - rhs.val + mod) % mod;
    }
    inline Int operator * (const Int &rhs) const {
        return 1ll * val * rhs.val % mod;
    }
};

线段树宏定义

#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid (l + r >> 1)
#define fc t[o]
#define lc t[ls]
#define rc t[rs]

fread IO 快读:

struct FastIO {
    static const int S = 1 << 20;
    char ibuf[S], *p, *q;
    inline char gc() {
        if (p == q) q = (p = ibuf) + fread(ibuf, 1, S, stdin);
        return p == q ? EOF : *p++;
    }
    template <typename T>
    inline bool read(T &x) {
        char ch = gc(); T f = 1; x = 0;
        if (ch == EOF) return 0;
        if (ch == '-') f = -1, ch = gc();
        while (ch < '0' || ch > '9') { if (ch == EOF) return 0; ch = gc(); }
        while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = gc();
        x *= f; return 1;
    }
} io;