码头


const int P = 998244353;
int power(int a, int b, int c = 1) {
    for(; b; b >>= 1, a = (ll)a * a % P) if(b & 1) c = (ll)c * a % P;
    return c;
}
struct mint {
    int x;
    mint(int _x = 0) { x = _x; }
    void rd() {cin >> x; x = (x % P + P) % P; }
    mint inv() {return power(x, P - 2); }
    friend mint operator + (const mint a, const mint b) { 
        return a.x + b.x >= P ? a.x + b.x - P : a.x + b.x; 
    }
    friend mint operator - (const mint a, const mint b) {
        return a.x - b.x < 0 ? a.x - b.x + P : a.x - b.x;
    }
    friend mint operator * (const mint a, const mint b) { return (ll)a.x * b.x % P; }
    friend mint operator / (const mint a, const mint b) { return power(b.x, P - 2, a.x); }
    friend mint& operator += (mint &a, const mint b) { return a = a + b, a; }
    friend mint& operator -= (mint &a, const mint b) { return a = a - b, a; }
    friend mint& operator *= (mint &a, const mint b) { return a = a * b, a; }
    friend mint& operator /= (mint &a, const mint b) { return a = a / b, a; }
    mint operator - () {return x ? P - x : x; }
};
struct mint {
    int x;
    mint() {x = 0; }
    mint(int _x) {x = _x; }
    friend mint operator + (const mint a, const mint b) {return (a.x + b.x) % P; }
    friend mint operator - (const mint a, const mint b) {return (a.x - b.x + P) % P; }
    friend mint operator * (const mint a, const mint b) {return 1ll * a.x * b.x % P; }
    friend mint operator ^ (mint a, int b) {
        mint c(1);
        for(; b; b >>= 1, a = a * a) if(b & 1) c = c * a;
        return c;
    }
    friend mint operator / (mint a, mint b) {return a * (b ^ (P - 2)); }
    friend mint &operator += (mint &a, const mint b) {return a = a + b; }
    friend mint &operator -= (mint &a, const mint b) {return a = a - b; }
    friend mint &operator *= (mint &a, const mint b) {return a = a * b; }
    friend mint &operator /= (mint &a, const mint b) {return a = a / b; }
} fac[N], ifac[N], inv[N];
void initmath(int n) {
    inv[1] = fac[0] = ifac[0] = 1;
    for(int i = 2; i <= n; i++) inv[i] = inv[P % i] * (P - P / i);
    for(int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i, ifac[i] = ifac[i - 1] * inv[i];
    return;
}
mint binom(int n, int m) {return n < m || m < 0 ? 0 : fac[n] * ifac[m] * ifac[n - m]; }
posted @ 2021-12-10 08:16  SegmentTree  阅读(55)  评论(0编辑  收藏  举报