二维树状数组
来源:互联网 发布:windows账户登录不了 编辑:程序博客网 时间:2024/05/16 07:51
#include <iostream>#include <algorithm>#include <string.h>#include <stdio.h>#include <math.h>#define LL long longusing namespace std;const int MAXN = 1e3+10;int dp[MAXN][MAXN];int lowbit(int k){return k&-k;}void updata(int n,int x,int y,int value){ for(int i = x; i <= n; i+=lowbit(i)){ for(int j = y; j <= n; j+=lowbit(j)){ dp[i][j] += value; } }}int query(int x,int y){ int sum = 0; for(int i = x; i > 0; i-=lowbit(i)){ for(int j = y; j > 0; j-=lowbit(j)) sum += dp[i][j]; } return sum;}int main(){ int n,a; cin>>n; memset(dp,0,sizeof(dp)); int m; cin>>m; int x,y,z,t; while(m--){ cin>>t; if(t==1){ cin>>x>>y; cout<<query(x,y)<<endl; } else{ cin>>x>>y>>z; updata(n,x,y,z); } }}
0 0
- pku1195 二维树状数组
- 二维树状数组
- 二维树状数组
- 树状数组 二维空间
- 二维树状数组
- 二维树状数组
- 二维树状数组
- POJ2155(二维树状数组)
- poj1195 二维树状数组
- 二维树状数组
- poj1195(二维树状数组)
- hdu1892二维树状数组
- 二维树状数组-poj2155
- 二维树状数组--poj1195
- 二维树状数组模版
- poj1656 二维树状数组
- Bzoj3132 二维树状数组
- 树状数组二维扩展
- 杨辉三角 HDU2032
- 业务知识——上诉、抗诉、起诉、自诉的区别
- Python处理验证码第一篇(pytesser初探及报错处理)
- JSP页面上的中文数据传到后台乱码处理汇总
- leetcode:二叉树之Construct Binary Tree from Preorder and Inorder Traversal
- 二维树状数组
- PL/SQL实例 navicat创建存储过程
- 一个关于椭圆曲线密码学的初级读本
- Android绘制间隔平行四边形虚线
- bootstrap table + spring + springmvc + mybatis 实现从前端到后端的表格分页
- 注册开发者账号出现Sorry, you can’t enroll at this time.
- SQL将一行多列数据合并成 一列
- Ehcache使用
- jquery( 点击按钮出来文本框并限制文本框的个数)