![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构--树状数组
文章平均质量分 80
hehe_54321
嘻嘻嘻
展开
-
洛谷 P1972 [SDOI2009]HH的项链
首先读入贝壳颜色,并建立 #include #include using namespace std; typedef long long LL; LL a[51000]; LL c[400100]; LL next1[51000]; LL ans[201000]; LL boo[1001000];//ji LL n,m,x,k=1,lastk; struct query1 { LL原创 2017-07-13 17:44:32 · 262 阅读 · 0 评论 -
洛谷 P1908 逆序对
P1908 逆序对 法一:归并排序求逆序对(记一下) #include int a[40001]; int a1[40001]; int num,n; void merge(int start,int mid,int end) { int k=start,k1=start,k2=mid+1; while(k1<=mid&&k2<=end) { i原创 2017-07-13 14:27:15 · 462 阅读 · 0 评论 -
笔记 树状数组--区间查询+区间修改
参考:点击打开链接 区间修改+区间查询的树状数组,实际上是用两个树状数组来表示一个数组 用a[i]表示原数组, d[i]=a[i]-a[i-1](a[i]视为0) 关于 的说明: a[1]+a[2]+...+a[x] =d[1]+(d[1]+d[2])+(d[1]+d[2]+d[3])+...+(d[1]+d[2]+...+d[x]) =d[1]*x+d[2]*(x-1)+..原创 2017-08-01 11:30:55 · 426 阅读 · 1 评论