Welcome To Ke_scholar's Blog|

Ke_scholar

园龄:2年1个月粉丝:30关注:10

随笔分类 -  模板

自适应辛普森法
摘要:自适应辛普森法 double a, b, c, d, l, r; const double eps = 1e-8; double F(double x) { //需要积分的公式 return (c * x + d) / (a * x + b); } double simpson(double l,
13
0
0
浮点高精度
摘要:简单封装了一下浮点加法乘法,未验证 struct BigFloat { static const int N = 100, n = 16; //位数,保留位数 vector<int> integer;//整数部分(逆序存储)123. -->321. vector<int> decimal;//小数部
28
0
0
Meissel_Lehmer模板
摘要:复杂度 \(O(n^\frac 23)\),计算 \(1\sim n\) 的素数个数 #define div(a, b) (1.0 * (a) / (b)) #define half(x) (((x) - 1) / 2) i64 Meissel_Lehmer(i64 n) { if (n <= 3)
16
0
0
int128输入输出流
摘要:using i128 = __int128; istream &operator>>(istream &is, i128 &x) { string s; is >> s; bool neg = false; x = 0; for (char c : s) { if (c == '-') neg =
38
0
0
线段树合并模板
摘要:template<class Node> struct PersidentSegmentTree { #define lc(u) tr[u].l #define rc(u) tr[u].r const int n; int tot = 0; vector<Node> tr; vector<int>
21
0
0
大数质因数分解模板
摘要:jiangly的(偷一下 i64 mul(i64 a, i64 b, i64 m) { return static_cast<__int128>(a) * b % m; } i64 power(i64 a, i64 b, i64 m) { i64 res = 1 % m; for (; b; b >
20
2
1
主席树模板
摘要:template<class Node> struct PersidentSegmentTree { #define lc(u) tr[u].l #define rc(u) tr[u].r #define val(u) tr[u].v const int n; int tot = 0; vector
15
1
0
线段树模板重制
摘要:template<class Node> struct SegmentTree { #define lc u<<1 #define rc u<<1|1 const int n, N; vector<Node> tr; SegmentTree(): n(0) {} SegmentTree(int n_
18
0
0
dsu on tree 模板
摘要:dsu on tree模板运用 例题以及代码: U41492 树上数颜色 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 记录详情 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) Lomsat gelral - 洛谷 | 计算机科学教育新生态 (luogu.com
23
0
0
树模板
摘要:struct Tree { int n, d = 0; //顶点,直径,树中心 //自顶向下u到其叶子结点最远距离d1,次长距离d2(与最长路径无公共边) //p1,p2表示结点u向下更新时是由哪个结点更新来的 //up表示结点u向上到祖宗结点的最远距离 vector<int> d1, d2, p1
18
0
0
字符串自然溢出哈希/单哈希/双哈希模板
摘要:自然溢出哈希 struct Hash { using u64 = unsigned long long; u64 base = 13331; vector<u64> pow, hash; Hash(string &s) { s = " " + s; int N = s.size(); pow.res
163
1
0
FFT 高精度乘法模板
摘要:#define L(x) (1 << (x)) const double PI = acos(-1.0); const int N = 1e7 + 10; double ax[N], ay[N], bx[N], by[N]; char sa[N / 2], sb[N / 2]; int sum[N]
33
0
0
取模+组合数
摘要:jiangly的板子 // 取模机 // using i64 = long long; template<class T> constexpr T power(T a, i64 b) { T res {1}; for (; b; b /= 2, a *= a) { if (b % 2) { res
82
1
0
SCC缩点模板
摘要:struct SCC { int top = 0, cntscc = 0, dfncnt = 0, n; vector<int> dfn, low, stk, instk; vector<int> sccnum, sccid; vector<vector<int>> g, scc; SCC(int
13
1
0
带修莫队模板
摘要:取分块大小 \(n^\frac{2}{3}\) 最优。 例题:数颜色 #include<bits/stdc++.h> using namespace std; using i64 = long long; const int N = 1e6 + 5; int cnt[N], a[N]; struct
12
0
0
莫队模板
摘要:#include<bits/stdc++.h> using namespace std; using i64 = long long; const int N = 1e6 + 5; int cnt[N], a[N]; struct query { int l, r, id; }; int main(
12
0
0
扫描线模板
摘要:#include<bits/stdc++.h> using namespace std; using i64 = long long; const int N = 1e6 + 5; //本模板是从左往右扫的,从下往上扫同理 #define ls (rt<<1) #define rs (rt<<1|1
20
1
0
线段树模板
摘要:#define lc u<<1 #define rc u<<1|1 const int N = 1e5 + 5; i64 w[N], n, m, p; struct Tree { //线段树 i64 l, r, sum, add, mul; } tr[N * 4]; void cal_lazy(i6
28
1
0
压位高精度模板
摘要:struct BigInteger { static const int BASE = 100000000; static const int WIDTH = 8; vector<int> s; BigInteger(long long num = 0) { *this = num; } BigIn
63
2
0
Exgcd 模板
摘要:Exgcd 模板 pair<int, int> exgcd(int a, int b) { if (b == 0)return make_pair(1, 0); auto [x, y] = exgcd(b, a % b); pair<int, int> ans = make_pair(y, x -
12
0
0
点击右上角即可分享
微信分享提示
深色
回顶
收起