poj1195 二维树状数组【pascal】
来源:互联网 发布:mac字典扩展 编辑:程序博客网 时间:2024/06/06 12:58
二维树状数组模板=。=
var tt,n,x,y,l,b,r,t,z:longint; i,j :longint; c :array[0..1025,0..1025] of longint;function lowbit(x:longint):Longint;begin exit(x and (-x));end;procedure add(x,y,z:longint);var t1,t2:longint;begin while (x<=n) do begin t1:=y; while (t1<=n) do begin inc(c[x,t1],z); inc(t1,lowbit(t1)); end; inc(x,lowbit(x)); end;end;function sum(x,y:longint):longint;var ans,y1:longint;begin ans:=0; while (x>0) do begin y1:=y; while (y1>0) do begin inc(ans,c[x,y1]); dec(y1,lowbit(y1)); end; dec(x,lowbit(x)); end; exit(ans);end;function find(l,b,r,t:longint):Longint;begin exit(sum(r,t)-sum(l-1,t)-sum(r,b-1)+sum(l-1,b-1));end;begin read(tt); while (tt<>3) do begin if (tt=0) then begin read(n); fillchar(c,sizeof(c),0); end else if (tt=1) then begin read(x,y,z); inc(x);inc(y); add(x,y,z); end else if (tt=2) then begin read(l,b,r,t); inc(l);inc(b);inc(r);inc(t); writeln(find(l,b,r,t)); end; read(tt); end;end.
——by Eirlys 0 0
- poj1195 二维树状数组【pascal】
- poj1195 二维树状数组
- poj1195(二维树状数组)
- 二维树状数组--poj1195
- 二维树状数组poj1195
- poj1195(二维树状数组)
- poj1195之二维树状数组
- poj1195 (二维树状数组)
- Poj1195(二维树状数组)
- POJ1195 Mobile phones, 二维树状数组
- poj1195 Mobile phones 二维树状数组
- POJ1195--Mobile phones--二维树状数组
- poj1195 mobile phones 【二维树状数组】
- poj1195及二维树状数组模板
- POJ1195 Mobile phones 【二维树状数组】
- poj1195--Mobile phones(二维树状数组)
- poj1195 Mobile phones 二维树状数组
- POJ1195 Mobile phones【树状数组】【二维】
- LifecycleProcessor not initialized
- Linux ALSA声卡驱动之六:ASoC架构中的Machine
- 欢迎使用CSDN-markdown编辑器
- Android 引入so包的两种方式
- 第十一周-OJ-E求两整数的最大公约数与最小公倍数
- poj1195 二维树状数组【pascal】
- caffe源码 之 Blob类
- redis
- Java 简介
- Python开发环境Spyder安装方法
- 安卓获得view的宽高
- IntelliJ IDEA 15快捷键大全
- cache映射
- java获取两个字符串日期之间的时间间隔天数,以及遍历这些天数