树状数组 改段求点
来源:互联网 发布:服务器架构设计软件 编辑:程序博客网 时间:2024/05/21 14:06
【1】修改操作:将A[l..r]之间的全部元素值加上c;
【2】求和操作:求此时A[x]的值。
操作【1】:updata(l-1, -c); updata(r, c);
操作【2】:query(x)。
#include <iostream>#include<cstdio>#include<cstring>#include <cmath>#include <queue>#include <stack>#include <algorithm>#include <cmath>#include <vector>#define LL long long#define MAXN 100000using namespace std;int sum[MAXN];int n;int lowbit(int index){ return index&(-index);}void updata(int index,int val){ while(index > 0){ sum[index] += val; index -= lowbit(index); }}int query(int index){ int ans = 0; while(index <= n){ ans += sum[index]; index += lowbit(index); } return ans;}int main(){ return 0;}
0 0
- 树状数组 改段求点
- 树状数组—改段求点
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 忘记Mysql的root密码解决方法
- session失效的几种方式
- 程序猿务必要提供自身英语能力,从现在开始!
- 性能不好怎么办?对着清单撸一遍
- 对数据结构的一些了解
- 树状数组 改段求点
- Android Service使用技巧
- 织梦dedecms TAG列表按最新发布时间排序的解决方法
- C++知识点
- Java中对象和对象引用
- 为织梦cms列表页文章缩略图添加alt属性的方法
- 阿牛的EOF串
- 织梦DedeCMS实现缩略图不拉伸变形的方法
- POJ 2524 - Ubiquitous Religions