1. 高斯消元
求矩阵逆, 增广单位阵然后消元
求行列式, 先消元后对角线乘积即为行列式
https://codeforces.com/contest/832/submission/61763466 (取模)
https://codeforces.com/contest/1344/submission/84584146 (bitset优化)
https://codeforces.com/gym/102501/submission/87009936 (bitset优化)
void Gauss(int A[N][N], int n, int m, int q) {
//A为n行m+q列矩阵, n为方程数, m为变量数
//q为增广的列数, r为矩阵秩
int r = 1;
REP(i,1,m) {
int p = r;
while (!A[p][i]&&p<=n) ++p;
if (p>n) continue;
if (p!=r) REP(j,1,m+q) swap(A[p][j],A[r][j]);
REP(j,1,n) if (j!=r&&A[j][i]) {
ll t = A[j][i]*inv(A[r][i])%P;
REP(k,1,m+q) A[j][k]=(A[j][k]-t*A[r][k]%P+P)%P;
}
++r;
}
}
2. exgcd
ll exgcd(ll a, ll b, ll &x, ll &y) {
ll d = a;
if (!b) return x=1,y=0,d;
return d=exgcd(b,a%b,y,x),y-=a/b*x,d;
}
3. 欧拉回路
https://codeforces.com/contest/1152/submission/84629674 (输出点)
https://codeforces.com/contest/1361/submission/84628129 (输出边)
void dfs(int x) {
while (g[x].size()) {
auto e = g[x].back(); g[x].pop_back();
if (!vis[e.y]) vis[e.y]=1, dfs(e.x);
}
r.push_back(x);
}
4. 平面图最大流
转为对偶图最短路问题
https://www.luogu.com.cn/record/35131137
https://ac.nowcoder.com/acm/contest/view-submission?submissionId=44220431
5. Pollard_Rho
https://nanti.jisuanke.com/mycode/2b43jexzyqga9nel/main.cpp
6. excrt
7. 极角排序
8. splay