http://poj.org/problem?id=1195

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1026
using namespace std; int a[maxn][maxn];
int c[maxn][maxn];
int S,x,y,aa,l,r,b,t,h,T; int lowbit(int x)
{
return x&(x^(x-));
} void update(int i,int j,int k)
{
while(i<=S)
{
int temp=j;
while(temp<=S)
{
c[i][temp]+=k;
temp+=lowbit(temp);
}
i+=lowbit(i);
}
} int sum(int i,int j)
{
int sum1=;
while(i>)
{
int temp=j;
while(temp>)
{
sum1+=c[i][temp];
temp-=lowbit(temp);
}
i-=lowbit(i);
}
return sum1;
} int main()
{
while(scanf("%d",&h))
{
if(h==)
{
scanf("%d",&S);
memset(c,,sizeof(c));
}
else if(h==) break;
else if(h==)
{
scanf("%d%d%d",&x,&y,&aa);
update(x+,y+,aa);
}
else if(h==)
{
scanf("%d%d%d%d",&l,&r,&b,&t);
int sum1=sum(b+,t+);
int sum2=sum(l,t+);
int sum3=sum(b+,r);
int sum4=sum(l,r);
printf("%d\n",sum1-sum2-sum3+sum4);
}
}
return ;
}

poj 1195Mobile phones的更多相关文章

  1. POJ——1195Mobile phones(二维树状数组点修改矩阵查询)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 17764   Accepted: 8213 De ...

  2. POJ 1195- Mobile phones(二维BIT)

    题意: 矩阵上的单点更新,范围求和 #include <map> #include <set> #include <list> #include <cmath ...

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

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

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

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

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

                                                                  Mobile phones Time Limit: 5000MS   Mem ...

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

    树状数组支持两种操作: Add(x, d)操作:   让a[x]增加d. Query(L,R): 计算 a[L]+a[L+1]……a[R]. 当要频繁的对数组元素进行修改,同时又要频繁的查询数组内任一 ...

  7. (简单) POJ 1195 Mobile phones,二维树状数组。

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

  8. ●POJ 1195 Mobile phones

    题链: http://poj.org/problem?id=1195 题解: 二维树状数组 #include<cstdio> #include<cstring> #includ ...

  9. Mobile phones POJ - 1195 二维树状数组求和

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

随机推荐

  1. Json序列化、反序列化互换

    // 序列化 using (MemoryStream stream = new MemoryStream()) { serializer.WriteObject(stream, hdm); jsonT ...

  2. Mac上安装pexpect

    1.首先安装pip sudo easy_install pip 2.pip安装pexpect sudo pip install pexpect

  3. 详谈typedef的用法

    我们都知道typedef是类型重定义,既然是重定义就不可能出现新的数据类型,只是将已有的数据类型进行换个名字而已,但是这有什么用呢?可能我们学的时候,给的例子都是:typedef int INT; 然 ...

  4. python-查询员工信息表

    python查询员工信息表 基本要求: 用户可以模糊查询员工信息 显示匹配了多少条,匹配字符需要高亮显示 代码: #!/usr/env python #coding:utf-8 import time ...

  5. poj 1201 Interval (查分约束)

    /* 数组开大保平安. 查分约束: 输入的时候维护st和end 设每个点取元素di个 维护元素个数前缀和s Sbi-Sai-1>=ci 即:建立一条从ai-1到bi的边 权值为ci 表示ai到b ...

  6. HDU5311

    题意:给一个指定的字符串a,要求分成三段,然后再给定另外一个字符串b,要求a中的三段能否在b中找到. 思路:枚举+模拟,首先枚举给定的字符串a,因为分成三段,所以一共有(1+9)*9/2种情况,对于分 ...

  7. HDU5308-脑补-对拍

    先贴上对拍的结果: 感想:可以明显发现下标相差1的关系,所以对付这种需要大量脑补的水题,真的蛋疼,以前没用过对拍,只知道有这么回事,调程序什么的都是手算,人工模拟(经常大脑发热,严重缺氧不足),所以试 ...

  8. CSS从大图中抠取小图完整教程(background-position应用) (转)

    自认为把background-position的应用讲得非常通俗易懂的教材.做个记号. 相信很多喜欢研究网页界面的童鞋都遇到过一个奇妙的现象:网页中很多图片素材被合成在一张图片上. 起初小菜模仿网站的 ...

  9. (转)ThinkPHP自定义模板标签详解

    转之--http://www.thinkphp.cn/topic/6258.html 模板标签让网站前台开发更加快速和简单,这让本该由程序猿才能完成的工作,现在只要稍懂得HTM的人也能轻易做到,这也就 ...

  10. .Net操作XML文件

    //设置配置文件物理路径 public string xmlPath = "/manage/spider/config.xml"; protected void Page_Load ...