Algorithm
文章平均质量分 76
安静de想着网名
300字以内
展开
-
位运算
位运算原创 2017-08-16 11:04:25 · 235 阅读 · 0 评论 -
HDU 2809 三国风云
At 184~280 A.D ,there were many kingdoms in China. Three strongest among them are “Wei”, “Shu”, “Wu”. People call this period as “Three Kingdoms”.原创 2017-09-07 14:14:02 · 497 阅读 · 0 评论 -
矩阵快速幂
求递推式,构造一个矩阵,根据矩阵乘法规则原创 2017-09-14 21:24:26 · 153 阅读 · 0 评论 -
AC自动机 模板
struct trie原创 2017-09-26 23:16:49 · 172 阅读 · 0 评论 -
主席树——区间第K大
Kth number原创 2017-09-27 21:51:33 · 276 阅读 · 0 评论 -
页面置换算法
CF-GYM-101498-F原创 2018-02-03 12:37:05 · 267 阅读 · 0 评论 -
小C的倍数问题
小C的倍数问题Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem Description根据小学数学的知识,我们知道一个正整数x是3的倍数的条件是x每一位加起来的和是3的倍数。反之,如果一个数每一位加起来是3的倍数,则这个数肯定是3的倍数。现在给定进制P原创 2017-08-14 19:04:56 · 190 阅读 · 0 评论 -
二维线段树之降维打击
COCI 2017/2018 ROUND#1DedaLittle Marica is making up a nonsensical unusual fairy tale and is telling to her grandfatherwho keeps interrupting her and asking her stupid intriguing questions.In Mar...原创 2018-03-12 12:21:19 · 450 阅读 · 0 评论 -
LCA 模板tarjan,欧拉序
#include<iostream>#include<stdio.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;typedef long long LL;const int原创 2018-04-26 16:42:18 · 183 阅读 · 0 评论 -
splay
#include<iostream>#include<stdio.h>#include<string>#include<string.h>#include<algorithm>using namespace std;const int MAXN = 100000 + 55;int L[MAXN], R[MAXN], F[MA...原创 2018-04-27 19:06:44 · 171 阅读 · 0 评论 -
HDU3577【线段树+区间更新+最值查询】
Fast ArrangementProblem DescriptionChinese always have the railway tickets problem because of its’ huge amount of passangers and stations. Now goverment need you to develop a new tickets query s...原创 2018-07-18 20:39:51 · 644 阅读 · 0 评论 -
gym/226036-F. Two Points【三分查找】
F. Two PointsThere are two points (x1, y1) and (x2, y2) on the plane. They move with the velocities (vx1, vy1) and (vx2, vy2). Find the minimal distance between them ever in future.InputThe firs...原创 2018-07-21 22:10:09 · 342 阅读 · 0 评论 -
可持久化线段树——主席树
支持访问任意历史版本以及在历史版本上修改的数据结构 每次修改不是在原有线段树上直接修改,而是在旁边新建点。 时空复杂度都是O(mlogn) const int N = 100000 + 5;//点数long long tree[N * 25], add_num[N * 25];int total, left_child[N * 25], right_child[N * 25], r...原创 2017-08-14 18:32:49 · 303 阅读 · 0 评论 -
About 日历
判断闰年,判断星期几原创 2017-08-12 14:54:25 · 450 阅读 · 0 评论 -
线段树
线段树是一个用一个数组,想象一棵完全二叉树,赋予其一些意义,数组中存储的信息即为每个节点数组中的0 是不用的。原创 2017-08-10 19:44:04 · 163 阅读 · 0 评论 -
Sunday 字符串匹配
主串为s,模式串为p s=abcdefg p=efgi abcdefgj efg首先从头开始比较,第一个字符不一样,那么新的下标m=i+ p.length,即s[m]=’d’然后在p中从后往前找’d’ ,即if(p[k]==s[m])发现没有则将p后移到e,即s[i]=’e’,p[j]=’e’若有则移动p使得下标k与m对齐int sunday(string s,string p ){原创 2018-01-07 15:30:08 · 188 阅读 · 0 评论 -
宽度优先搜索
Breadth First Search宽度优先搜索算法(又称广度优先搜索)是最简便的图的搜索算法之一,这一算法也是很多重要的图的算法的原型。Dijkstra单源最短路径算法和Prim最小生成树算法都采用了和宽度优先搜索类似的思想。其别名又叫BFS,属于一种盲目搜寻法,目的是系统地展开并检查图中的所有节点,以找寻结果。换句话说,它并不考虑结果的可能位置,彻底地搜索整张图,直到找到结果为止。原创 2017-08-10 19:43:42 · 410 阅读 · 0 评论 -
超超超简单的bfs——POJ-3278
Catch That CowTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 89836 Accepted: 28175DescriptionFarmer John has been informed of the location of a fugitive cow and wants to原创 2017-08-10 19:43:40 · 256 阅读 · 0 评论 -
超超超简单的bfs——POJ-1915
Knight MovesTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 26102 Accepted: 12305DescriptionBackground Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else原创 2017-08-10 19:43:45 · 210 阅读 · 0 评论 -
计算几何
1.1三角形1. 半周长 P=(a+b+c)/22. 面积 S=aHa/2=absin(C)/2=sqrt(P(P-a)(P-b)(P-c))3. 中线 Ma=sqrt(2(b^2+c^2)-a^2)/2=sqrt(b^2+c^2+2bccos(A))/24. 角平分线 Ta=sqrt(bc((b+c)^2-a^2))/(b+c)=2bccos(A/2)/(b+c)5. 高线 Ha=bs原创 2017-08-10 19:44:13 · 271 阅读 · 0 评论 -
度度熊与邪恶大魔王 DP | 完全背包
Problem Description度度熊为了拯救可爱的公主,于是与邪恶大魔王战斗起来。邪恶大魔王的麾下有n个怪兽,每个怪兽有a[i]的生命值,以及b[i]的防御力。度度熊一共拥有m种攻击方式,第i种攻击方式,需要消耗k[i]的晶石,造成p[i]点伤害。当然,如果度度熊使用第i个技能打在第j个怪兽上面的话,会使得第j个怪兽的生命值减少p[i]-b[j],当然如果伤害小于防御,那么攻击就原创 2017-08-10 19:44:18 · 228 阅读 · 0 评论 -
acm 模板
卢卡斯定理 主席树 Sunday AC自动机 链式前向星#include&amp;amp;lt;string.h&amp;amp;gt;#define MAX 10000struct node{ int to,nex,wei;}edge[MAX*2+5];int head[MAX+5],cnt;void add(int u,int v,int w)//添加一个单向边u-&amp;amp;gt;v 权为w {...原创 2017-08-11 17:47:51 · 296 阅读 · 0 评论 -
线段树(初级)
#define MAX 10000 //待处理的点数,不是树中的节点数int tree[MAX * 4];void build(int t, int l, int r){ if (l == r) { //cin>>tree[t]; //tree[t]=0; //对叶子初始化 return; }原创 2017-08-11 18:05:55 · 161 阅读 · 0 评论 -
二分图最大匹配
POJ 3041原创 2017-08-11 18:13:47 · 192 阅读 · 0 评论 -
Lucas 组合数取模
组合数取模就是求 CnmmodpCmnmodpC^n_m\mod p 的值,当然根据n,m,pn,m,pn,m,p的取值范围不同,采取的方法也不一样。 ppp比较大就只能一个一个算如LL C_one_by_one(LL n, LL m)//组合数一个一个算但是不是很大的要预先处理好阶乘 数很大需要逆元typedef long long LL;LL MOD;LL fac[...原创 2018-01-31 20:53:05 · 193 阅读 · 0 评论 -
矩阵快速幂模板
矩阵快速幂取模数加const!!!!!const ll m = 123456789;ll k;int N = 6;struct matrix{ ll g[N][N]; matrix operator=(const matrix &b) { for (int i = 0; i < n; i++) { ...原创 2019-03-17 19:42:53 · 139 阅读 · 0 评论