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. CentOS7 盒盖休眠

    https://wiki.archlinux.org/index.php/Power_management_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) CentOS ...

  2. 数位DP初步 bzoj1026 hdu2089 hdu3555

    为了搞SCOI的几道题先做水数位.之前听过课,半懂不懂吧,现在清楚了些. 这类题一般满足区间减法,即只需要我们求出(1,n)即可,然后打表也是为了sovle(DataType)服务.先想好怎么计算,再 ...

  3. 赵雅智_ListView_BaseAdapter

    Android界面中有时候须要显示略微复杂的界面时,就须要我们自己定义一个adapter,而此adapter就要继承BaseAdapter,又一次当中的方法. Android中Adapter类事实上就 ...

  4. 第七讲:HTML5中的canvas两个小球全然弹性碰撞

    <html> <head> <title>小球之间的碰撞(全然弹性碰撞)</title> <script src="../js/jsce ...

  5. Eclipse中输入系统变量和运行参数--转

    原文地址:http://chenzhou123520.iteye.com/blog/1931670 在开发时,有时候可能需要根据不同的环境设置不同的系统参数,我们都知道,在使用java -jar命令时 ...

  6. Undefined symbols for architecture i386

    这个错误的发生原因一般是“XXX”这个文件(类库)虽然引入了工程中,但是由于种种原因(常见于多人开发,svn同步不规范)导致“XXX”并未被添加到project.pbxproj这个文件中. 解决方法是 ...

  7. TCP/IP协议原理与应用笔记09:数据通信---封装

    2016-08-091. 数据通信----封装: 2. 协议数据单元: PDU:对等层数据通信的单元. 比如Source端的应用层 和 Destination端的应用层是对等层(L7),这个时候L7 ...

  8. android studio上代码编译调试中遇到的一些异常记录

    下面是记录的在平时代码编写或编译时的一些异常,答案有自己摸索出来的,也有参考其他程序猿朋友的,参考文章过多,就不一一贴出来了. ① E/JavaBinder: !!! FAILED BINDER TR ...

  9. SQL 里面的COALESCE函数

    在SQL里面除了is null 还有这样一个还用的方法 COALESCE(值[, ...]) select COALESCE(NULL,NULL,'AAAA') -> 'AAAA' 意思是前面的 ...

  10. repeater控件 + marquee标签 实现文字滚动显示

    各种信息网站.BBS等网站上的公告信息模块的实现 拖出一个repeater控件绑定数据库中要显示的信息 在repeater的 <ItemTemplate> ... </ItemTem ...