树状数组
来源:互联网 发布:mac dock图标大小 编辑:程序博客网 时间:2024/06/05 18:35
#include<cstdio>#include<iostream>#include<cstring>using namespace std;const int N=1e3;int n,m;namespace AA{ int cc[N]; void add(int x,int v){ while(x<=n){ cc[x]+=v;x+=x&-x; } } int query(int x){ int ans=0; while(x){ ans+=cc[x];x-=x&-x; } return ans; }}namespace BB{ int cc[N][N]; void add(int x,int y,int v){ for(int i=x;i<=n;i+=i&-i){ for(int j=y;j<=m;j+=j&-j){ cc[i][j]+=v; } } } int query(int x,int y){ int ans=0; for(int i=x;i;i-=i&-i){ for(int j=y;j;j-=j&-j){ ans+=cc[i][j]; } } return ans; }}int main(){ return 0;}
0 0
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 树状数组
- 最小表示
- 百度搜索URL参数你知道多少
- html float 浮动
- Win7 下使用 VS2015 交叉编译最新 libcurl 7.51.0(包含openssl-1.0.2j,zlib-1.2.8)
- uva 331 Mapping the Swaps
- 树状数组
- K-means算法对地图上点进行聚类(未修订篇)
- 多层循环的跳出(return goto break continue 的用法与区别)
- spring4之搭建restful风格的web服务
- 树链剖分
- 用IBExpert管理firebird
- 机器学习(四):BP神经网络_手写数字识别_Python
- 莫队
- RTMPDump开源工程