签名
增加 1 行删除 1 行
1flijkyd | 简单,直接,哈气,爽1简单,直接,哈气,爽
个人介绍
增加 37 行删除 138 行
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316439 行未改动https://www.bilibili.com/video/BV1GJ411x7h7/https://www.zhihu.com/question/296095491/answer/2031828199886280553## Mod int```cpptemplate <const int mod>class mod_int {private:int x;typedef mod_int <mod> mint;public:mod_int () : x (0) { }template <class _Tp> mod_int (_Tp _x) {x = (_x % mod + mod) % mod;}~mod_int () = default;mod_int (const mod_int &other): x (other.x) { }# if __cplusplus >= 201402Lmod_int (mod_int &&other) noexcept: x (std :: exchange (other.x, 0)) { }# elsemod_int (mod_int &&other) noexcept {const int tmp = other.x;other.x = 0;this -> x = tmp;}# endifmod_int &operator = (const mint &other) {return *this = mint (other);}mod_int &operator = (mint &&other) noexcept {std :: swap (x, other.x);return *this;}int val () const {return x;}explicit operator int () const {return x;}explicit operator long long () const {return (long long) x;}// plusfriend mint operator + (const mint &a, const mint &b) {const int tmp = a.x + b.x;return mint (tmp >= mod ? tmp - mod : tmp);}mint &operator += (const mint &other) {return *this = *this + other;}mint &operator ++ () {return *this = *this + mint (1);}mint operator ++ (int) {const mint old = *this;*this = *this + mint (1);return old;}// minusfriend mint operator - (const mint &a, const mint &b) {const int tmp = a.x - b.x;return mint (tmp < 0 ? tmp + mod : tmp);}mint operator - () const {const int tmp = mod - this -> x;return tmp < mod ? tmp : tmp - mod;}mint &operator -= (const mint &other) {return *this = *this - other;}mint &operator -- () {return *this = *this - mint (1);}mint operator -- (int) {const mint old = *this;*this = *this - mint (1);return old;}// multiplyfriend mint operator * (const mint &a, const mint &b) {const int tmp = (long long) a.x * b.x % mod;return mint (tmp);}mint &operator *= (const mint &other) {return *this = *this * other;}// divisiontemplate <class _Tp>friend il mint qpow (mint base, _Tp p) {if (p <= 0)return mod_int (1);mint tmp (1);for (; p; p >>= 1) {if (p & 1)tmp *= base;base *= base;}return tmp;}friend il mint inv (mint x) {return qpow (x, mod - 2);}// use carefullyfriend mint operator / (const mint &a, const mint &b) {const mint inv_b = inv (b);return a * inv_b;}mint &operator /= (const mint& other) {return *this = *this / other;}friend bool operator == (const mint &a, const mint &b) {return a.x == b.x;}friend bool operator != (const mint &a, const mint &b) {return a.x != b.x;}};```[1](https://www.zhihu.com/question/2072260638768997299/answer/2082088964106752772)39 行未改动12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626339 行未改动::::info[玩一些音游]超爽快节奏 15 & 18:https://beta.sparebeat.com/play/0b38efc4::::CSh2BKSqFjZb2cQ4khBs6n6Ov4sRFaLuXC48cyOZEW3BkZhttps://www.bilibili.com/video/BV1GJ411x7h7/https://www.zhihu.com/question/296095491/answer/2031828199886280553## Mod int```cpptemplate <const int mod> class mod_int {private:int x;typedef mod_int <mod> Q;public:mod_int () : x (0) { }template <class _Tp> mod_int (_Tp _x) { x = (_x % mod + mod) % mod; }~mod_int () = default;mod_int (const mod_int &other) : x (other.x) { }# if __cplusplus >= 201402Lmod_int (mod_int &&other) noexcept : x (std :: exchange (other.x, 0)) { }# elsemod_int (mod_int &&other) noexcept { const int tmp = other.x; other.x = 0; this -> x = tmp; }# endifmod_int &operator = (const Q &other) { return *this = Q (other); }mod_int &operator = (Q &&other) noexcept { std :: swap (x, other.x); return *this; }int val () const { return x; }template <class _Tp> explicit operator _Tp () const { return _Tp (x); }friend Q operator + (const Q &a, const Q &b) { const int v = a.x + b.x; return Q (v >= mod ? v - mod : v); }Q &operator += (const Q &other) { return *this = *this + other; }Q &operator ++ () { return *this = *this + Q (1); }Q operator ++ (int) { const Q old = *this; *this = *this + Q (1); return old; }friend Q operator - (const Q &a, const Q &b) { const int v = a.x - b.x; return Q (v < 0 ? v + mod : v); }Q operator - () const { return Q (this -> x ? mod - this -> x : 0); }Q &operator -= (const Q &other) { return *this = *this - other; }Q &operator -- () { return *this = *this - Q (1); }Q operator -- (int) { const Q old = *this; *this = *this - Q (1); return old; }friend Q operator * (const Q &a, const Q &b) { const int v = (long long) a.x * b.x % mod; return Q (v); }Q &operator *= (const Q &other) { return *this = *this * other; }template <class _Tp> friend inline Q qpow (Q base, _Tp p) {if (p <= 0) return mod_int (1);Q tmp (1); for (; p; p >>= 1, base *= base) if (p & 1) tmp *= base; return tmp;}friend inline Q inv (Q x) { return qpow (x, mod - 2); }friend Q operator / (const Q &a, const Q &b) { const Q inv_b = inv (b); return a * inv_b; }Q &operator /= (const Q& other) { return *this = *this / other; }friend bool operator == (const Q &a, const Q &b) { return a.x == b.x; }friend bool operator != (const Q &a, const Q &b) { return a.x != b.x; }};```[1](https://www.zhihu.com/question/2072260638768997299/answer/2082088964106752772)39 行未改动