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. 【BZOJ4327】JSOI2012 玄武密码 AC自动机

    [BZOJ4327]JSOI2012 玄武密码 Description 在美丽的玄武湖畔,鸡鸣寺边,鸡笼山前,有一块富饶而秀美的土地,人们唤作进香河.相传一日,一缕紫气从天而至,只一瞬间便消失在了进香 ...

  2. C++重载解析

    重载解析(overloading resolution)的规则决定了编译器为一个函数调用选用哪个函数定义.一般过程如下: 将名称相同的函数/模板函数找到并创建候选列表 从中挑选参数数目正确,符合完全匹 ...

  3. C# 解析js方法,并调用js方法

    本文转载:http://www.cnblogs.com/StudyLife/archive/2013/03/11/2953516.html 本文不是基于B/S的 后台调用前台js方法,而是给你一段js ...

  4. Win8 移除右键菜单中的SkyDrive Pro选项

    Step 1:进入注册表编辑器 Win + R键调出运行窗口,然后输入regedit,进入注册表编辑器. Step 2:删除下面的键值 HKEY_CLASSES_ROOT\AllFilesystemO ...

  5. Delphi 2007体验!

    Delphi 2007体验! baidu 内容摘要:CodeGear(From Borland) 公司公布了最新的Delphi 2007 For Win32版本号.作为一个 Delphi 的使用者,第 ...

  6. padding与margin的差别

    之前一直没有搞懂android:padding和android:layout_margin的差别,事实上概念非常easy,padding是站在父view的角度描写叙述问题,它规定它里面的内容必须与这个 ...

  7. [转] HTML中调用JavaScript的几种情况和规范写法

    比较简单,基础. 一.引用外部文件中的js脚本 <script type="text/javascript" src="ext.js"></s ...

  8. Thinkphp 3.2及以上版本实现支付宝担保交易、即时到账接口类、函数和使用方法

    给客户开发网站时需要用到支付宝在线付款功能,小云到thinkphp网站溜了一圈,代码是有,可是都不怎么全,因此这篇文章诞生了! 本篇文章讲解了三个类的实现,担保交易.即时到账.双功能收款(该功能支付宝 ...

  9. C#解leetcode 18. 4Sum

    Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...

  10. VS2008试用版到期解决办法

    在Windows 7下,VS2008试用版无法正常升级到正式版.原因是维护页面的注册码输入框和升级按钮被隐藏.通过本补丁,可让注册码输入框和升级按钮恢复正常显示 点击此处下载补丁 1.安装完90天试用 ...