正文
增加 99 行删除 0 行
1234561,299 行未改动全部展开如有特殊情况有标注 qwq。:::info[龟速乘]```cppll qmul(ll a, ll b, ll mod){ll res = 0;1,299 行未改动全部展开1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051,299 行未改动全部展开如有特殊情况有标注 qwq。:::info[$\times +$ 矩阵快速幂]```cppstruct mat{int n, m;vector <vector <int>> a;mat(int _n = 0, int _m = 0){n = _n;m = _m;a.resize(n + 1, vector <int> (m + 1, 0));}void I(int _n = 0){n = _n;m = _n;a.resize(n + 1, vector <int> (m + 1, 0));for (int i = 1; i <= n; i ++ ){a[i][i] = 1;}}const mat operator *(const mat b){mat a = *this;mat res(a.n, b.m);for (int i = 1; i <= a.n; i ++ ){for (int j = 1; j <= b.m; j ++ ){for (int k = 1; k <= a.m; k ++ ){res.a[i][j] = (res.a[i][j] + 1ll * a.a[i][k] * b.a[k][j] % mod) % mod;}}}return res;}const mat operator *=(const mat b){return (*this = *this * b);}};mat qpow(mat a, ll b){mat res(a.n, a.m);res.I(a.n);while (b){if (b & 1){res *= a;}a *= a;b >>= 1;}return res;}mat qpow(mat st, mat a, ll b){mat res = st;while (b){if (b & 1){res *= a;}a *= a;b >>= 1;}return res;}```::::::info[BIT ver2]```cpptemplate <class T, int N>struct BIT{T tr[N + 5];void update(int x, T y){while (x <= N) tr[x] += y, x += x & (-x);}T query(int x){T ans = 0;while (x) ans += tr[x], x -= x & (-x);return ans;}T range(int l, int r){ return query(r) - query(l - 1); }};```::::::info[Tarjan 缩点]```cppint dfn[N], id[N], tot, low[N];vector <int> stk, g[N];bool inq[N]; int bel[N], scc, cnt[N];void tarjan(int u){stk.push_back(u), inq[u] = true;dfn[u] = low[u] = ++ tot, id[tot] = u;for (auto v : g[u]){if (!dfn[v]) tarjan(v), low[u] = min(low[u], low[v]);else if (inq[v]) low[u] = min(low[u], dfn[v]);}if (dfn[u] == low[u]){scc ++ ; int now;do{now = stk.back(), stk.pop_back(), pot[scc].push_back(now);inq[now] = false, cnt[scc] ++, bel[now] = scc;} while (now != u);}}```::::::info[龟速乘]```cppll qmul(ll a, ll b, ll mod){ll res = 0;1,299 行未改动全部展开