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 ...
随机推荐
- 51nod——2476 小b和序列(预处理 思维)
对于每一个元素,预处理出它作为最小值,两边可以作用到的最大位置.比如下标∈[0,8]的这个数组:1 8 6 2 5 4 3 8 7,1可以作用到所有区间,2可以作用到区间[1,8],第一个8可以作用到 ...
- 洛谷P1164小A点菜
这也是一道01背包的题 用的方法比较的巧妙.这个动态规划相当于反过来做的,自己理解就知道了.代码很短 #include<bits/stdc++.h> using namespace std ...
- 自动化测试 ubuntu多设备连接不识别
环境: ubuntu系统 usb2.0 16个口集线器 遇到问题: 连接手机到第11台设备时出现adb devices不显示的现象导致无法通过adb操作 问题排除思路; 1.通过dmesg查看设备连接 ...
- 全文检索ES 服务启动和关闭
nohup ./elasticsearch & 可以后台开启elasticsearch服务 ps-ef列出所有进程 ps-ef | grep elastic...查找elastic..的进程 ...
- Apache 查找httpd.conf文件
Linux下查找httpd.conf文件 $ find / -name httpd.conf
- win10下安装mysql-5.7.23-winx64
Step1 官方下载地址 https://dev.mysql.com/downloads/mysql/ 选择手动下载版本 解压到自己指定的路径 上图中的my.ini及data文件夹在压缩包里是没有的, ...
- php下关于Cannot use a scalar value as an array的解决办法
今天在测试php程序的时候,出现了一个错误提示:Cannot use a scalar value as an array,这个错误提示前几天也出过,当时好像稍微调了一下就好了,也没深究,今天却又出现 ...
- DeepFaceLab进阶(4):通过Colab免费使用Tesla K80 跑模型!
当学会了换脸软件DeepFaceLab基本使用,各种参数配置,各有优化技能之后.唯一约束你的可能是电脑配置. CPU能跑,但是慢到怀疑人生,低配模型都得跑一周 低配显卡,显存不够,H128 根本就跑不 ...
- 第37课 thinkphp5添加商品基本信息及通过前置钩子上传商品主图 模型事件(勾子函数)
目录 手册地址: before_insert(新增之前的操作) 要实现的功能 思路 触发条件: 1. 控制器里必须要调用模型的save()方式保存数据,用insert()触发不了勾子函数的 2. 模型 ...
- Harbor HA部署-使用Ceph RADOS后端
1. 前言 Harbor 1.4.0版本开始提供了HA部署方式,和非HA的主要区别就是把有状态的服务分离出来,使用外部集群,而不是运行在本地的容器上.而无状态的服务则可以部署在多个节点上,通过配置上层 ...