Solost

Category: ACM笔记

快速排序

void quick_sort(int q[], int l, int r) { if (l >= r) return; int i = l - 1, j = r + 1, x = q[l + r >> 1]; while (i < j…
Solost2025 年 09 月 21 日0 条评论

AcWing 860. 染色法判定二分图

链接) #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 100010 * 2; i…
Solost2024 年 03 月 29 日0 条评论

AcWing 867. 分解质因数

题目链接 链接 代码 #include <iostream> #include <algorithm> using namespace std; void divide(int x) { for (int i = 2; i <= …
Solost2023 年 09 月 12 日0 条评论

AcWing 869. 试除法求约数

题目链接 题目链接 代码 #include <iostream> #include <algorithm> #include <vector> using namespace std; vector<int> g…
Solost2023 年 09 月 12 日0 条评论

试除法求约数

#include <iostream> #include <algorithm> #include <vector> using namespace std; vector<int> get_divisors(i…
Solost2023 年 08 月 02 日0 条评论

组合数

ll C(ll n,ll m){ ll ans = 1; for(ll i =1;i<=m;i++){ ans = ans * (n-m+i)/i; // 注意一定要先乘再除 } return ans; }
Solost2023 年 07 月 06 日0 条评论

Kruskal

kruskal int n, m; // n是点数,m是边数 int p[N]; // 并查集的父节点数组 struct Edge // 存储边 { int a, b, w; bool operator< (const Edge &W)const…
Solost2023 年 04 月 17 日0 条评论

Prime

prime 模板 /* S:当前已经在联通块中的所有点的集合 1. dist[i] = inf 2. for n 次 t<-S外离S最近的点 利用t更新S外点到S的距离 st[t] = true n次迭代之后所有点都已加入到S中 联系:Dijkstra算…
Solost2023 年 04 月 17 日0 条评论

ST表

ST表 原理 首先声明几点: st[i][j]表示这段区间上从第i个位置自己开始起,往后数2^i个数之间的最大值 lg[i]表示不超过i的最大2次幂指数(就是2的i次方不超过i且i尽量大) 输出RMQ最值的时候,最好用函数来写 第一部分:输入并预处理lg数组 …
Solost2023 年 04 月 14 日0 条评论