
树状数组
yohanlong
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
树状数组的两种运用
运用1单点修改,区间查询。 add(pos,x)->在下标 pos 处加上 x query(pos)->返回 1 到 pos 的前缀和 那么查询区间 [ l , r ]的操作就是query( r ) - query( l - 1 )例题——洛谷3374代码#include<cstdio> #include<cstring> #include<algorithm> #include<cs原创 2016-11-09 16:48:53 · 245 阅读 · 0 评论 -
【学习笔记】树状数组求逆序对
直接上代码。 时间复杂度与归并排序一致,但是好写多了有木有。#include <cstdio> using namespace std; int a[6]={0,5,2,1,4,3}; int c[6]; int lowbit(int x){ return x&(-x); } void update(int pos,int val){ while(pos<=5){原创 2016-11-11 17:47:02 · 457 阅读 · 0 评论