二维树状数组板子题。

 #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. 第27题:Leetcode226: Invert Binary Tree反转二叉树

    翻转一棵二叉树. 示例: 输入: 4 / \ 2 7 / \ / \ 1 3 6 9 输出: 4 / \ 7 2 / \ / \ 9 6 3 1  思路 如果根节点存在,就交换两个子树的根节点,用递归 ...

  2. 四、Linux 忘记密码解决方法

    Linux 忘记密码解决方法 很多朋友经常会忘记Linux系统的root密码,linux系统忘记root密码的情况该怎么办呢?重新安装系统吗?当然不用!进入单用户模式更改一下root密码即可. 步骤如 ...

  3. mysql安装记录

    一.创建mysql用户 useradd mysql 二.解压 tar -zxvf mysql-5.6.38.tar.gz 三.安装依赖包 yum install -y ncurses-devel li ...

  4. Python_常用模块

    一.内置模块 定义:其实模块简单说就是一堆代码实现某个功能,它们是已经写好的.py文件.只需要用import应用即可. 分类: 1. 自定义模块,就是自己写的.py文件为了实现某个功能. 2. 内置标 ...

  5. 了解并使用springAOP(面向切面编程)

    Aop是干嘛的为什么要使用它 在业务系统中,总有一些散落,渗透到系统的各处且不得不处理的事情,这些穿插在既定业务中的操作就是所谓的“横切逻辑”,也称切面, 我们怎样才不受这些附加要求的干扰,专心于真正 ...

  6. Python中字符串String的基本内置函数与过滤字符模块函数的基本用法

    Python中字符串String的基本内置函数与用法 首先我们要明白在python中当字符编码为:UTF-8时,中文在字符串中的占位为3个字节,其余字符为一个字节 下面就直接介绍几种python中字符 ...

  7. 学习pytho第l六天 常用字符串用法

    name='my name is dream' print(name.capitalize())#首字母大写 print(name.count(‘’a‘’))#判断字符串里有多少个a print(na ...

  8. Linux命令之---nl

    命令简介 nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 cat -n 有点不太一样, nl 可以将行号做比较多的显示设计,包括位数与是否自动补 ...

  9. firewall-cmd 防火墙命令详解 及 TCP Wrappers

    firewall-cmd 常用参数及作用 参数 作用 --get-default-zone 查询默认的区域名称 --set-default-zone=<区域名称> 设置默认的区域,使其永久 ...

  10. Diycode开源项目 LoginActivity分析

    1.首先看一下效果 1.1.预览一下真实页面 1.2.分析一下: 要求输入Email或者用户名,点击编辑框,弹出键盘,默认先进入输入Email或用户名编辑框. 点击密码后,密码字样网上浮动一段距离,E ...