- 博客(31)
- 收藏
- 关注
原创 半平面交
#include <cstdio>#include <cmath>#include <algorithm>using namespace std;const double eps = 1e-8;int Sign(double x) { if (fabs(x) < eps)return 0; return x < 0 ? -1 : 1;}struct Point { double x, y;} ans[505];.
2020-09-07 21:10:04
163
原创 树状数组求最值+单点修改
#include <cstdio>#include <algorithm>using namespace std;const int max_n = 200005;int n, a[max_n], tree[max_n];inline int low_bit(int x) { return x & -x; }inline void Change(int p, int x) { a[p] = x; for (int i = p; i &l.
2020-09-01 21:27:19
254
原创 可持久化fhq
#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;const int max_n = 5e5 + 5;struct Fhq { int ch[2], val, key, sze;} fhq[max_n * 50];int tot = 0, root[max_n];inline int New_Code(int val) { int.
2020-08-25 14:35:49
310
原创 极角排序+凸包
#include <cstdio>#include <algorithm>#include <cmath>using namespace std;int n;const int MAXN = 1e5 + 5;struct Point { double x, y;} p[MAXN], Stack[MAXN];int Top = 0;bool cmp1(Point u, Point v) { if (u.y == v.y)retu.
2020-08-17 13:05:54
229
原创 海伦秦九韶
#include <cstdio>#include <cmath>using namespace std;const double eps = 1e-8;struct Point { double x, y;};struct Vector { double x, y;};double Distance(Point A, Point B) { double dx = A.x - B.x; double dy = A.y - B.
2020-08-15 19:45:25
293
原创 模拟退火
#include <cstdio>#include <cmath>#include <algorithm>using namespace std;const double delta = 0.996;const double eps = 1e-15;double X, Y;struct Point { double x, y;} a[1005], ans;int n;double ans_val = 0;double Min_Va.
2020-08-14 20:54:28
119
原创 两圆相交面积
#include <cstdio>#include <cmath>using namespace std;const double PI = acos(-1);struct Point { double x, y;};struct Round { Point o; double r;};double Cos(double a, double b, double c) { return (a * a + b * b - c *.
2020-08-14 16:50:14
177
原创 逆矩阵
#include <cstdio>#include <algorithm>using namespace std;#define int long longconst int mod = 1e9 + 7;int n, a[405][405], b[405][405];int Power(int q, int c) { if (c == 0)return 1; if (q == 0)return 0; int ans = Power(q .
2020-08-12 20:35:55
118
原创 点分治
#include <cstdio>#include <algorithm>using namespace std;const int max_n = 1e4 + 5;int n, k;struct Edge { int to, next, val;} edge[max_n * 2];int head[max_n];int ans = 0;bool vis[max_n];int mx_son[max_n], sze[max_n];int F.
2020-08-07 19:19:23
100
原创 三点确定一个圆
struct Point { double x, y;} a[max_n];struct Round { double r; Point o; bool On_Round(Point p) { return (p.x - o.x) * (p.x - o.x) + (p.y - o.y) * (p.y - o.y) <= r * r; }};Round Make_Round(Point p) { return {0, p};.
2020-08-03 20:09:54
440
原创 后缀数组
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int max_n = 1e5 + 5;int n, m;char s[max_n];int des[max_n], d = 0;int Rank[max_n], Sa[max_n], Height[max_n], tax[max_n], tp[max_n];void Rank_S.
2020-07-17 20:56:56
112
原创 广义后缀自动机
#include <cstdio>#include <cstring>#include <algorithm>#include <queue>using namespace std;const int max_n = 1e6 + 5;char s[max_n];struct Trie { int ch[26]{}, fth, pos; Trie() { for (int &i:ch)i = 0;.
2020-07-09 12:01:30
176
原创 Manacher
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int max_n = 1e5 + 5;char s[max_n], a[max_n * 2];int n = 0, t, len[max_n * 2], pre[max_n], suf[max_n];signed main() {// freopen("in", "r", std.
2020-06-02 20:33:00
128
原创 回文自动机
#include <cstdio>#include <cstring>using namespace std;const int max_n = 500005;struct Palindromic_Tree { int next[max_n][26]{}, fail[max_n]{}; //next指针,next指针和字典树类似,指向的串为当前串两端加上同一个字符构成 //fail指针,失配后跳转到fail指针指向的节点 int cnt.
2020-05-19 21:38:00
156
原创 大整型
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define int long longconst int base = 1e18;struct BigInt { int num[1000]{}, len; BigInt() { len = 0; } void Assign(int x) { len = .
2020-05-15 15:27:54
147
原创 高斯消元
#include <cstdio>using namespace std;int n;double a[105][105], b[105];signed main() { scanf("%d", &n);//NOLINT for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++)scanf("%lf", &a[i][j]);//NOLINT sc.
2020-05-15 11:28:13
186
原创 高次同余方程
int Power(int q, int n, int p) { if (n == 0)return 1 % p; if (q == 0)return 0; int ans = Power(q * q % p, n / 2, p); if (n & 1)ans *= q;//NOLINT return ans % p;}int BSGS(in...
2020-04-26 18:38:22
274
原创 最小斯坦纳树
#include <cstdio>#include <algorithm>#include <queue>using namespace std;const int INF = 0x3f3f3f3f;int n, m, k, start[105], a[15], dp[105][1 << 10];//NOLINT;struct E...
2020-04-23 21:29:32
186
原创 线段树合并
#include <cstdio>#include <vector>#include <algorithm>#include <queue>using namespace std;const int MAXN = 1e5 + 5;int n, m;struct Edge { int to, next;} edge[MAX...
2020-04-21 20:49:46
105
原创 后缀自动机
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 1e6 + 5;char s[MAXN];int n = 0;int tot = 1, last = 1;struct Suffix_Automaton {...
2020-04-17 11:31:28
130
原创 Splay
int n, root = 0;struct Tree { int lef, rgh, num, sze, fth;} tree[MAXN];inline void Rotate(int x) { int y = tree[x].fth; int z = tree[y].fth; if (root == y)root = x; else if (t...
2020-04-06 10:54:39
92
原创 杜教筛
#include <cstdio>#include <unordered_map>using namespace std;const int N = 5000000;int prime[N + 5], min_prime[N + 5], cnt = 0;long long pre_miu[N + 5], pre_phi[N + 5];unordered_ma...
2020-04-05 20:55:26
119
原创 Mobius 2
求 1 <= i <= n, 1 <= j <= m 范围的 d(i * j) 的和,d(x) 为 x 的因子个数#include <cstdio>#include <algorithm>using namespace std;#define int long longconst int MAXN = 50005;int prim...
2020-04-05 16:44:52
105
原创 Mobius
求 1 <= x <= n, 1 <= y <= m 中 gcd(x, y) 为质数的个数#include <cstdio>#include <algorithm>using namespace std;const int MAXN = 1e7 + 5;int is_prime[MAXN], miu[MAXN], prime[MAXN...
2020-04-05 15:25:53
117
原创 拓展Lucas
#include <cstdio>using namespace std;#define int long longint P[50], D[50], cnt = 0, B[50];int Power(int q, int n, int mod) { if (n == 0)return 1; if (q == 0)return 0; int res...
2020-04-04 13:54:45
144
原创 Lucas
int Power(int q, int n, int p) { if (n == 0)return 1 % p; return Power(q * q % p, n / 2, p) % p * (n & 1 ? q : 1) % p;}int Factorial(int n, int p) { if (n >= p)return 0; if ...
2020-04-03 19:02:44
136
原创 线性同余方程
int Extend_Gcd(int a, int b, int &x, int &y) { if (b == 0) { x = 1, y = 0; return a; } int d = Extend_Gcd(b, a % b, x, y); int z = x; x = y; y = z - y ...
2020-04-03 18:27:29
178
原创 fhq
struct Treap { int lef, rgh, pos;} fhq[100005 * 205];int root = 0, tot = 0;queue<int> que;int tmp[100005], cnt = 0;int Build(int l, int r) { if (l > r)return 0; int ans = q...
2020-03-26 14:01:52
463
原创 左偏树
#include <cstdio>#include <algorithm>using namespace std;#define int long longconst int MAXN = 100005;int n, m;int fth[MAXN], Val[MAXN], Pow[MAXN];struct Edge { int to, next;...
2020-03-25 21:17:07
81
原创 Treap模板
#include <iostream>#include <algorithm>const int INF = 0x7fffffff;const int MAXN = 100005;using namespace std;int root = 0;struct { int lef, rgh; int val, key; int cnt...
2020-01-12 15:48:02
98
原创 等比数列求和模板
#define mod ....//随便填int qpow(int n, int m) { int ans = 1; while (m) { if (m & 1)ans *= n, ans %= mod; m /= 2; n *= n; n %= mod; } return ans;}int ers(int q, int n) { if (n == 0)retur...
2019-09-23 21:00:10
180
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人