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. vue-cli 中 使用vue-resource 输出后台数据

    阅读此文前,请了解vue-cli 组件如何使用  http://www.cnblogs.com/pearl07/p/6252116.html 1,mock(模拟)后台数据(新建data.Json文件) ...

  2. Hard 随机选择subset @CareerCup

    算法同上题 package Hard; import CtCILibrary.AssortedMethods; /** * Write a method to randomly generate a ...

  3. android scrollview组件禁止滑动的方法

    xml配置:           android:id="@+id/sc_freement"             android:layout_width="fill ...

  4. Percona Live 2016 PPT整理-zhaiwx_yinfeng

    https://yq.aliyun.com/articles/54454?spm=5176.100239.bloglist.32.CllwIr

  5. JQ插件之imgAreaSelect实现对图片的在线截图功能(java版)

    前言:在做网站的时候经常用的功能就是,用户上传图片对自己上传的图片进行截图,DIV自己的头像.或者上传幻灯片大图进行DIV设置小图. 解决方案:目前我知道的解决方案有两个如下:       一.fla ...

  6. python一些技巧

    1. 使用目录管理 sys.path.append(sys.argv[0][:sys.argv[0].rfind('com'+os.sep+'abc')]) from com.abc.libs imp ...

  7. Android(java)学习笔记227:服务(service)之服务的生命周期 与 两种启动服务的区别

    1.之前我们在Android(java)学习笔记171:Service生命周期 (2015-08-18 10:56)说明过,可以回头看看: 2.Service 的两种启动方法和区别: (1)Servi ...

  8. Python之路,Day4 - Python基础4 (new版)

    Python之路,Day4 - Python基础4 (new版)   本节内容 迭代器&生成器 装饰器 Json & pickle 数据序列化 软件目录结构规范 作业:ATM项目开发 ...

  9. Facade 门面模式 外观模式

    简介 作用: (1)封装一组交互类,一致地对外提供接口 (2)封装子系统,简化子系统调用 JDK中体现:java.util.logging包 java.lang.Class javax.faces.w ...

  10. phonegap 2.8.1 toast

    目录结构如下: 以上三个用红色框勾出的地方是需要修改的文件夹. 首先:添加java代码. 在src目录下新建一个包裹:org.apache.cordova 在该包裹下新建类:ToastPlugin.j ...