二维树状数组板子题。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define inf 1000000000
#define maxn 40000
#define eps 1e-12
#define mod 1000000007
#define N 3005
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>'') {if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<='') {x=*x+ch-'';ch=getchar();}
return x*f;
}
int c[N][N],n;
int lowbit(int i)
{
return i&(-i);
}
int sum(int x,int y)
{
int ret=;
for(int i=x;i>;i-=lowbit(i))
{
for(int j=y;j>;j-=lowbit(j))
ret+=c[i][j];
}
return ret;
}
void add(int x,int y,int d)
{
for(int i=x;i<=n;i+=lowbit(i))
for(int j=y;j<=n;j+=lowbit(j))
{
c[i][j]+=d;
}
}
int main()
{
int k,op,x,y,i,j;
while(~scanf("%d%d",&i,&n))
{
mem(c,);
while()
{
op=read();
if(op==) break;
if(op==) {
x=read();y=read();k=read();
add(x+,y+,k);
}
else{
int l,b,r,t;
l=read();b=read();r=read();t=read();
l++;b++;r++;t++;
printf("%d\n",sum(r,t)-sum(r,b-)-sum(l-,t)+sum(l-,b-));
}
}
}
return ;
}

POJ1195Mobile phones的更多相关文章

  1. POJ1195--Mobile phones(基础二维BIT)

    Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...

  2. POJ1195Mobile phones (从二维树状数组到cdq分治)

    Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...

  3. poj1195Mobile phones(二维树状数组)

    http://poj.org/problem?id=1195 模版题 i写成k了 找了一个多小时没找出来.. #include <iostream> #include<cstring ...

  4. poj 1195:Mobile phones(二维树状数组,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14489   Accepted: 6735 De ...

  5. poj 1195:Mobile phones(二维线段树,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14391   Accepted: 6685 De ...

  6. POJ 1195 Mobile phones(二维树状数组)

                                                                  Mobile phones Time Limit: 5000MS   Mem ...

  7. Deal with Android phones with pattern lock on

    Yesterday my colleague asked me for help...She has two android phones , one is hTC and the other is ...

  8. C. Mobile phones

    Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...

  9. 【POJ1195】【二维树状数组】Mobile phones

    Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...

随机推荐

  1. awk截取指定字段

    #!/bin/bash #好多地方可以优化,先记录下,便于以后使用 dir="/logs/$1"file="/logs/$1/requests.log"if [ ...

  2. Laravel — homestead 配置多站点

    一.homestead.yaml 配置 homestead.yaml 文件配置sites,如下 sites: - map: homestead.test to: /home/vagrant/Code/ ...

  3. 一个手机号可以注册绑定5个百度网盘,永久2T

    效果: 一个手机号可以注册绑定5个百度网盘,得永久2T硬盘 手机号只能做为其中一个网盘的登陆账号,其它四个用绑定qq登陆(微信应该也可以). 条件: 2个手机号:A(用来绑定百度网盘),B(用来申请网 ...

  4. kafka及扩展的安装笔记

    参考文件 https://blog.csdn.net/weiwenjuan0923/article/details/76152744 一.首先确认下jdk有没有安装 安装参照这个连接 https:// ...

  5. linux 的安装

    3linux 软件安装 3.1 vm ware 软件安装 双击VMware-workstation-full-10.0.2-1744117.1398244508.exe 单击下一步 单击下一步 选择典 ...

  6. linux Ubuntu18.04 安装配置MySQL

    1.安装 ubuntu上安装mysql非常简单只需要几条命令就可以完成. 1. sudo apt-get install mysql-server   2. apt-get install mysql ...

  7. Scrapy用pipelines把字典保存为csv格式

    import csv class MyProjectPipeline(object): # 保存为csv格式 def __init__(self): # 打开文件,指定方式为写,利用第3个参数把csv ...

  8. 使用HTTP协议访问网络

    在Android上发送http请求有2种方式,分别由两个类完成,HttpURLConnection和HttpClient. 一.使用HttpURLConnection方式 1.1 建立连接的基本步骤 ...

  9. 动态规划:HDU1003-Max Sum(最大子序列和)

    Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  10. 二分答案:Poweroj2461-入门基础之二分答案(二分法的应用)

    传送门:点击打开链接 入门基础之二分答案 Time Limit: 1000 MS Memory Limit: 65536 KBTotal Submit: 179 Accepted: 33 Page V ...