跳到正文

System32

766582

私は陰暗でうねうね動くウジ虫だ

这是 2026年10月19日 存档的第 1 版,不是当前版本。查看当前版本

资料、奖项与版本

资料

编号
766582
抓取

奖项

2025 CSP-J
一等奖
2025 CSP-S
一等奖
2024 CSP-J
一等奖
2024 CSP-S
一等奖
2023 CSP-J
一等奖
2022 CSP-J
二等奖

版本

  1. v2当前
  2. v1

2207431509

C++
template <typename T, T mod, typename U = long long>
struct mint {
    T val;
    static const U one = 1;
    mint() { val = 0; }
    mint(T _v) { val = _v; }
    mint(string str) : val(0) {
        for (char c : str) val = (one * val * 10 + (c - '0')) % mod;
    }
    friend mint operator+(const mint &a, const mint &b) {
        return mint(a.val + b.val >= mod ? a.val + b.val - mod : a.val + b.val);
    }
    friend mint operator*(const mint &a, const mint &b) { return mint(one * a.val * b.val % mod); }
    void operator+=(const mint &a) { *this = *this + a; }
    void operator*=(const mint &a) { *this = *this * a; }
    friend mint operator-(const mint &a, const mint &b) {
        return mint(a.val + mod - b.val >= mod ? a.val - b.val : a.val + mod - b.val);
    }
    void operator-=(const mint &a) { *this = *this - a; }
    friend mint pow(mint a, T b) {
        mint res = 1;
        while (b) {
            if (b & 1) res = res * a;
            a = a * a, b >>= 1;
        }
        return res;
    }
    mint inv() { return pow(*this, mod - 2); }
    friend ostream &operator<<(ostream &os, mint a) { return os << a.val, os; }
    friend istream &operator>>(istream &is, mint &a) {
        string str;
        return is >> str, a = mint(str), is;
    }
};