随笔分类 - 模板
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll inf = 0x3f3f3f3f; const ll N = 5e5 + 9; struct edg
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ld eps = 1e-8; const int N = 50009; const ld pi = aco
阅读全文
摘要:计算时间 cout << "Totle Time : " << (double)clock() /CLOCKS_PER_SEC<< "s" << endl;
阅读全文
摘要:kmp #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll N = 1e6 + 9; const ll inf = 0x3f3f3f3f; char a
阅读全文
摘要:ll fac[N], inv_fac[N]; ll q_pow(ll a, ll b, ll mod) { ll ret = 1; for (ll x = a; b; b >>= 1, (x*=x)%=mod){if (b&1)(ret *= x)%=mod;} return ret; } ll i
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll N = 1e6 + 9; const ll inf = 0x3f3f3f3f; ll exgcd(l
阅读全文
摘要:int pr[N], pr_cnt, flg[N], mu[N], sum_mu[N]; void init() { mu[1] = 1; for (int i = 2; i < N; i ++) { if (!flg[i])pr[++pr_cnt] = i, mu[i] = -1; for (in
阅读全文
摘要:ll rand_int(ll l, ll r) { //[l, r] #ifdef LOCAL static mt19937_64 gen; #else static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().coun
阅读全文
摘要:const ll maxn = 10; struct Matrix { ld a[maxn][maxn]; int n; Matrix (int sz, int kind) { this->n = sz; for (int i = 0; i < sz; i ++) { for (int j = 0;
阅读全文
摘要:const ll maxn = 1e6 + 9; ll st[maxn][25]; ll sst[maxn][25]; ll ssg[maxn][25]; ll LOG2[maxn]; ll query_max(ll l, ll r) { ll k = LOG2[r - l + 1]; return
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = 9000000; const ld pi = acos(-1); struct CP {
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 1e6 + 9; ll a[N]; vector<ll>G[N]; ll sz[N], Son[N]; ll Max= -1; ll co;
阅读全文
摘要:树链剖分 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e5 + 9; template <typename T> inline void read(T &x) { register
阅读全文
摘要:三元环 问题描述,给定无向图,然后求出三元环个数 建图做法:先把无向图转化为 \(DAG\) ,把边去重,然后把度数从小的点连向度数大的点。 显然的是,每个三元环只能被找到一次。 时间复杂度证明: 可知边 \((x, y)\) 被遍历的次数是 \(out_y\),所以总复杂度是 \(m\times
阅读全文
摘要:\(\varphi (x) = p_1^{k1-1} (p_1-1) \times p_2^{k2-1} (p2-1) \times p_3^{k3-1}(p3-1)\) \(\varphi (x) =x \times \frac{(p_1-1)}{p_1} \times \frac{(p_2-1)
阅读全文
摘要:Hash #include <algorithm> #include <cstring> #include <iostream> #include <vector> #include <map> using namespace std; typedef long long ll; typedef u
阅读全文
摘要:#include <iostream> #include <algorithm> #include <cstdio> using namespace std; const int N = 2e5 * 20; int a[N], b[N], root[N]; struct President_Tree
阅读全文
摘要:#include<iostream> #include<cstdio> #include<cmath> #include <cstring> #include <queue> #include <stack> #include <set> #include <map> #include <vecto
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e5 + 9; ll n, m, root; ll a[N]; struct segmentTree { struct node {
阅读全文
摘要:网络流模板 EK求最大可行流 #include <iostream> #include <queue> #include <cstring> using namespace std; const int N = 2000, M = 20090; int h[N], ne[M], to[M], f[M
阅读全文