![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
xiao_you_you
这个作者很懒,什么都没留下…
展开
-
浅谈ST表
ST表用以解决RMQ问题(给定一个长度为N的区间,M个询问,每次询问Li到Ri这段区间元素的最大值/最小值)。复杂度nlog(n)原理: 预处理:·一种利用dp求解区间最值的倍增算法。区间在增加时,每次并不是增加一个长度,而是使用倍增的思想,每次增加2^i个长度。·设二维数组st[i][j],表示需要查询的数组的从下标i到向后延伸2^j - 1长度(即下标i+2^j - 1)的最值...原创 2019-04-06 09:44:31 · 146 阅读 · 0 评论 -
凸包模版
#include <cstdio>#include <cmath>#include <vector>#include <algorithm>#include <cstring>#include <iostream>using namespace std;const double PI = acos(-1.0);...原创 2019-04-28 19:18:36 · 75 阅读 · 0 评论 -
问题 M: Little Sub and Johann
思路:直接用SG函数会超时,对SG函数打一下表找规律。可以发现当x为质数时,sg[x]=x是第几个质数+1。当x不为质数时,sg[x]=sg[p]且p是x的最小质因子。#include<iostream>#define ll long long#include <stdio.h>#include <string.h>#define N 10...原创 2019-05-05 16:20:01 · 97 阅读 · 0 评论 -
SG函数模版
#include <stdio.h>#include <string.h>#define MAXN 1000 + 10#define N 20//f[N]:可改变当前状态的方式,N为方式的种类,f[N]要在getSG之前先预处理//SG[]:0~n的SG函数值//S[]:为x后继状态的集合int f[N],SG[MAXN],S[MAXN];void ge...原创 2019-05-05 16:32:40 · 103 阅读 · 0 评论 -
旋转卡壳模版(求凸包直径)
#include <cstdio>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 100022 << 2;struct Point{ int x, y; Point( int x = 0, int y = 0 ):x(...原创 2019-04-30 16:15:33 · 363 阅读 · 0 评论 -
半平交面模版
//半平面交(返回半平面交点的个数)//点p在有向直线L的左边bool OnLeft(Line L, Point p){ return Cross(L.v, p-L.P) > 0;}//二直线交点。假定交点唯一存在Point GetIntersection(Line a, Line b){ Vector u = a.P-b.P; double t =...原创 2019-04-30 21:39:41 · 114 阅读 · 0 评论 -
Best Solver HDU - 5451 (共轭构造)
The so-called best problem solver can easily solve this problem, with his/her childhood sweetheart.It is known thaty=(5+26–√)1+2xy=(5+26)1+2x.For a given integerx(0≤x<232)x(0≤x<232)and ...原创 2019-06-25 12:32:44 · 148 阅读 · 0 评论 -
D.Modulo Nine (DP)
思路:若要a1*a2*a3....*an能mod9等于0,则该算式中必有两个因子3相乘或者含有0。对于一个右端点r,有多个[l,r]的时候,只要最小的那个区间满足,其他肯定都满足了。这样对于一个右端点的限制条件是否满足,取决于前面出现的最后两个3出现的位置(9和0算作两个3)由此我们设dp[i][j][k]表示前i个数,最后一个因子3出现的位置为j,倒数第二个为k。由于因子中含有3的数有3、...原创 2019-10-06 11:28:01 · 186 阅读 · 0 评论 -
I. Misunderstood … Missing (DP)
Warm sunshine, cool wind and a fine day, while the girl watching is pursuing in chaos. Rikka reached out her hand and got the garland on her head, finding LCR with the immortal smile. The dream ended ...原创 2019-10-06 15:27:04 · 668 阅读 · 0 评论