随笔分类 -  模板

摘要:快速乘 解决int64*int64%int64问题 移位快速乘,思想是把a*b%p中的b,对其进行二进制拆分,把b拆成二进制形式 a*b=ck-1*a*2k-1+ck-2*a*2k-2+ck-3*a*2k-3+....+c0*a*20 其中c代码二进制位是否为1,我们只需要把b每次&1看最后一位是否 阅读全文
posted @ 2019-12-17 15:36 bluefly-hrbust 阅读(382) 评论(0) 推荐(0)
摘要:#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> using namespace std; const int maxx = 2e5+6; struct node{ int rt,l,r,val,pos,dis; node(){ l=r=val=dis=pos=0; } }tree[maxx]; 阅读全文
posted @ 2019-09-25 01:00 bluefly-hrbust 阅读(171) 评论(0) 推荐(0)
摘要:struct node{ int l,r; mutable int v; node(int L,int R,int V):l(L),r(R),v(V){} inline bool operator s; typedef set::iterator IT; int ans; inline IT split(int pos){ IT it = s.lower_boun... 阅读全文
posted @ 2019-09-10 00:49 bluefly-hrbust 阅读(183) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; int main(){ while(true) { system("data.exe>data.in"); system("ac.exe<data.in>ac.out"); system("wa.exe<data.in>wa.out"); if(system("fc ac.out wa.out")) { sy 阅读全文
posted @ 2019-08-31 09:48 bluefly-hrbust 阅读(222) 评论(0) 推荐(0)
摘要:怎么代码都这么长。。。 阅读全文
posted @ 2019-08-24 22:57 bluefly-hrbust 阅读(162) 评论(0) 推荐(0)
摘要:替罪羊树,代码贼长,我哭了。。。 #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>#include<vector>using namespace std;const int maxn = 1e5+5;co 阅读全文
posted @ 2019-08-24 17:16 bluefly-hrbust 阅读(249) 评论(0) 推荐(0)
摘要:树链剖分模板 阅读全文
posted @ 2019-08-22 23:19 bluefly-hrbust 阅读(226) 评论(0) 推荐(0)
摘要:void get_next() { net[1]=0;//不要用next for (int i=2,j=0; i0 && t[i]!=t[j+1])j=net[j]; if(t[i]==t[j+1])j++; net[i]=j; } } 阅读全文
posted @ 2019-03-27 20:39 bluefly-hrbust 阅读(154) 评论(0) 推荐(0)
摘要:这里大概讲解一下整除分块的原理和效果。 比如我们要求某个i的区间中,n/i的和是多少,但是其实你会发现,在一些连续的区间中,n/i是相等的,而整除分块的目的,便是按照n进行分块 使得可以跳过这些n/i是相等的这些区间,使得复杂度将到根号n 阅读全文
posted @ 2019-03-26 14:42 bluefly-hrbust 阅读(288) 评论(0) 推荐(0)
摘要:比较优秀的线性筛 比较垃圾的普通筛法 阅读全文
posted @ 2019-03-25 20:59 bluefly-hrbust 阅读(230) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std; int sum1[1000]; int sum2[1000]; int a[1000]; int n,m; int lowbit(int x){ return x&(-x); } void update(int x,int w){//更新效果:把x位置后面所有的数的值+w ... 阅读全文
posted @ 2019-02-22 23:17 bluefly-hrbust 阅读(187) 评论(0) 推荐(0)
摘要:void init(){for(int i=1;i<=maxx;i++)pre[i]=i;}//初始化 //注意如果序列内节点编号是大于n的,要初始化到最大,建议最开始初始化到最大 int Find(int x){return pre[x]==x?x:(pre[x]=Find(pre[x]));}//状态压缩+找最上面的祖先 void join(int x,int y){fx=Find(x);... 阅读全文
posted @ 2019-01-16 23:50 bluefly-hrbust 阅读(232) 评论(0) 推荐(0)
摘要:struct M { LL a[3][3]; void init1()//化单位矩阵 { memset(a, 0, sizeof(a)); a[0][0]=1; a[1][1]=1; a[2][2]=1; } void init0()//清空矩阵 { memset(a, ... 阅读全文
posted @ 2018-10-26 00:27 bluefly-hrbust 阅读(244) 评论(0) 推荐(0)
摘要:对于求某个数的欧拉函数,我们可以通过公式直接求解,这里做出简单证明 代码实现 阅读全文
posted @ 2018-10-23 21:00 bluefly-hrbust 阅读(201) 评论(0) 推荐(0)