poj 1195Mobile phones
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的更多相关文章
- POJ——1195Mobile phones(二维树状数组点修改矩阵查询)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 17764 Accepted: 8213 De ...
- POJ 1195- Mobile phones(二维BIT)
题意: 矩阵上的单点更新,范围求和 #include <map> #include <set> #include <list> #include <cmath ...
- poj 1195:Mobile phones(二维树状数组,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14489 Accepted: 6735 De ...
- poj 1195:Mobile phones(二维线段树,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14391 Accepted: 6685 De ...
- POJ 1195 Mobile phones(二维树状数组)
Mobile phones Time Limit: 5000MS Mem ...
- poj 1195 Mobile phones(二维树状数组)
树状数组支持两种操作: Add(x, d)操作: 让a[x]增加d. Query(L,R): 计算 a[L]+a[L+1]……a[R]. 当要频繁的对数组元素进行修改,同时又要频繁的查询数组内任一 ...
- (简单) POJ 1195 Mobile phones,二维树状数组。
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
- ●POJ 1195 Mobile phones
题链: http://poj.org/problem?id=1195 题解: 二维树状数组 #include<cstdio> #include<cstring> #includ ...
- Mobile phones POJ - 1195 二维树状数组求和
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...
随机推荐
- IOS UITextField 设置光标位置
textField.leftView = [[[UIView alloc] initWithFrame:CGRectMake(, , , )] autorelease]; textField.left ...
- jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档
原文:https://docs.jboss.org/author/display/AS7/Java+API+for+RESTful+Web+Services+(JAX-RS) Content Tuto ...
- GDataXML的配置和使用
1.下载链接:http://code.google.com/p/gdata-objectivec-client/downloads/list下载“gdata-objective-c client li ...
- Java基础知识强化之IO流笔记06:有return的情况下try catch finally的执行顺序
1. 给出结论: (1)不管有木有出现异常,finally块中代码都会执行:(2)当try和catch中有return时,finally仍然会执行:(3)finally是在return后面的表达式运算 ...
- Mac上安装pexpect
1.首先安装pip sudo easy_install pip 2.pip安装pexpect sudo pip install pexpect
- Linux下/etc/fstab文件详解
当系统启动的时候,系统会自动地从这个文件读取信息,并且会自动将此文件中指定的文件系统挂载到指定的目录. [root@rusky ~]# vi /etc/fstab # # /etc/fstab # C ...
- 格雷码(Gray Code)转二进制码(Binary Code)
学习verilog generate语句时,偶然看到用generate语句来进行格雷码到二进制码转换的代码,就从网上找了一些案例来学习. 下表为几种自然二进制码与格雷码的对照表: 十进制数 自然二进制 ...
- JavaScript自动关闭窗口
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- HDU5319
题意:给一个矩形染色,顺笔表示红色,逆笔表示蓝色(既一捺和一丿),交叉表示绿色,然后给你一个图,问你用多少笔能画出这个图来. 思路:对这个图直接模拟即可,如果点i,j坐标为红色,那么判断上一个路径点是 ...
- 使用WebUploader使用,及使用后测试横拍或竖拍图片图片方向不对等解决方案
WebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件.在现代的浏览器里面能充分发挥HTML5的优势,同时又不摒弃主流IE浏览 ...