
莫队算法
qianyri
这个作者很懒,什么都没留下…
展开
-
HDU6333 Problem B. Harvest of Apples 莫队算法+乘法逆元
HDU6333 Problem B. Harvest of Apples 莫队算法 求(0,n)~(m,n)组合数之和 #include <bits/stdc++.h> using namespace std; const int MAX=1e5+5; const int BLOCK=(int)sqrt(1e5); const long long MOD=1e9+7; long...原创 2018-08-02 11:43:02 · 609 阅读 · 0 评论 -
SP10707 COT2 - Count on a tree II 树上莫队模板
SP10707 COT2 - Count on a tree II 树上莫队=树链剖分+莫对算法 给定一个n个节点的树,每个节点表示一个整数,问u到v的路径上有多少个不同的整数。 #include<cstdio> #include<cmath> #include<algorithm> #include<vector> //#define ge...原创 2018-09-19 21:20:31 · 240 阅读 · 0 评论 -
codeforce940 F. Machine Learning 带修莫队
给定一个带修改的序列,求一个区间中最小的未出现的数的个数 单点修改,区间查询 任意离散化+带修莫队(可持续化,按时间进程记录修改先后的值的版本) #include<bits/stdc++.h> using namespace std; const int MAX=2e5+5; int n,m,cntq,cntc,cntid,block,a[MAX],now[MAX],vis[M...原创 2018-09-20 20:33:57 · 188 阅读 · 0 评论 -
codeforce617 E. XOR and Favorite Number 异或 莫队
E. XOR and Favorite Number 求区间内连续区间异或运算为K的区间对数 预处理异或前缀 当 b[r]^K=b[l-1]时区间r~l的值为K cnt[i]记录 所在区间内值为i的个数 若i^K=l/r 则相应加减 , 其中l的值为给定的l -1 因为在区间l~r内 b[r]对答案没有贡献 #include<bits/stdc++.h> using name...原创 2018-10-11 22:18:03 · 228 阅读 · 0 评论