POJ1195Mobile phones
二维树状数组板子题。
- #include<cstdio>
- #include<cstring>
- #include<iostream>
- #include<cstdlib>
- #include<algorithm>
- #include<cmath>
- #include<vector>
- using namespace std;
- #define mem(a,b) memset(a,b,sizeof(a))
- #define ll long long
- #define inf 1000000000
- #define maxn 40000
- #define eps 1e-12
- #define mod 1000000007
- #define N 3005
- inline int read()
- {
- int x=,f=;char ch=getchar();
- while(ch<''||ch>'') {if(ch=='-') f=-;ch=getchar();}
- while(ch>=''&&ch<='') {x=*x+ch-'';ch=getchar();}
- return x*f;
- }
- int c[N][N],n;
- int lowbit(int i)
- {
- return i&(-i);
- }
- int sum(int x,int y)
- {
- int ret=;
- for(int i=x;i>;i-=lowbit(i))
- {
- for(int j=y;j>;j-=lowbit(j))
- ret+=c[i][j];
- }
- return ret;
- }
- void add(int x,int y,int d)
- {
- for(int i=x;i<=n;i+=lowbit(i))
- for(int j=y;j<=n;j+=lowbit(j))
- {
- c[i][j]+=d;
- }
- }
- int main()
- {
- int k,op,x,y,i,j;
- while(~scanf("%d%d",&i,&n))
- {
- mem(c,);
- while()
- {
- op=read();
- if(op==) break;
- if(op==) {
- x=read();y=read();k=read();
- add(x+,y+,k);
- }
- else{
- int l,b,r,t;
- l=read();b=read();r=read();t=read();
- l++;b++;r++;t++;
- printf("%d\n",sum(r,t)-sum(r,b-)-sum(l-,t)+sum(l-,b-));
- }
- }
- }
- return ;
- }
POJ1195Mobile phones的更多相关文章
- POJ1195--Mobile phones(基础二维BIT)
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
- POJ1195Mobile phones (从二维树状数组到cdq分治)
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...
- poj1195Mobile phones(二维树状数组)
http://poj.org/problem?id=1195 模版题 i写成k了 找了一个多小时没找出来.. #include <iostream> #include<cstring ...
- 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 ...
- Deal with Android phones with pattern lock on
Yesterday my colleague asked me for help...She has two android phones , one is hTC and the other is ...
- C. Mobile phones
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...
- 【POJ1195】【二维树状数组】Mobile phones
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
随机推荐
- CentOS---JDK安装与配置
1.先查看一下CentOS中存在的jdk安装包信息 # rpm -qa | grep java 查看CentOS安装的jdk版本 #java -version 2.分别执行以下命令将所有相关包都删除 ...
- LeetCode948-令牌放置
问题:令牌放置 你的初始能量为 P,初始分数为 0,只有一包令牌. 令牌的值为 token[i],每个令牌最多只能使用一次,可能的两种使用方法如下: 如果你至少有 token[i] 点能量,可以将令牌 ...
- LigerUI 快速开发UI框架 链接
LigerUI 快速开发UI框架 http://www.ligerui.com/ jQuery ligerUI 中文官方网站 http://www.ligerui.com/demo.html
- ecshop里提出来的js常用函数
目录 Utils.js jquery.listTable.js 使用例子: ecshop里提出来的js常用函数 Utils.js /* $Id : utils.js 5052 2007-02-03 1 ...
- 如何将emoji表情存放到mysql数据库中
昨晚在爬取猫眼电影评论时在将评论信息插入到数据库中时出现问题,总是在插入一条数据时就会报错: 看着应该时字符编码的问题,比如新建的数据库新建的表,默认字符编码是:Latin1, 这种编码是无法插入中文 ...
- 动态规划:HDU2844-Coins(多重背包的二进制优化)
Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- hadoop启动时权限不足
之前在使用时的没用去懂.ssh,后来因为一些情况直接将其权限修改为777. 第一位7等于4+2+1,所以就是rwx,所有者有读取.写入.执行的权限:第二位7也是4+2+1,rwx,同组用户具有读取.写 ...
- 笔记-python-反射
笔记-python-反射 1. 反射 在很多地方看到自省和反射,很晕菜,整理了一下相关文档,加深了理解. 自省和反射其实说的是一件事,核心操作是根据输入去对象(模块)中调用(查找/获取/删除/添加)成 ...
- 用私有构造器或者枚举类型强化Singleton属性
1.Singleton指仅仅被实例化一次的类.Singleton通常被用来代表那些本质上唯一的系统组件,如窗口管理器或者文件系统.使类称为Singleton会使它的客户端调试变的十分困难,因为无法给S ...
- Python之print函数详解
输出的 print 函数总结: 1. 字符串和数值类型可以直接输出 >>> print(1) 1 >>> print("Hello World" ...