题意:基础的二维数组,注意 0 + lowbit(0)会陷入无限循环-----

之前做一道一维的一直tle,就是因为这个--------------------------

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; int c[][];
int n; int lowbit(int x){ return x & (-x);} int sum(int x,int y){
int ret = ,y1;
while(x > ){
y1 = y;
while( y1 > ){
ret += c[x][y1];y1 -= lowbit(y1);
}
x-=lowbit(x);
}
return ret;
} void add(int x,int y,int d){
int y1;
while(x <= n){
y1 = y;
while(y1 <= n){
c[x][y1] += d; y1 += lowbit(y1);
}
x += lowbit(x);
}
} int main(){
int cmd;
while(scanf("%d %d",&cmd,&n) != EOF){
memset(c,,sizeof(c));
while(scanf("%d",&cmd) != EOF && cmd != ){
if(cmd == ){
int x,y,d;
scanf("%d %d %d",&x,&y,&d);x++;y++;
add(x,y,d);
}
else{
int x,y,xx,yy;
int ret = ;
scanf("%d %d %d %d",&x,&y,&xx,&yy);
x++;y++;xx++;yy++;
ret = sum(xx,yy) - sum(x-,yy) - sum(xx,y-) + sum(x-,y-);
printf("%d\n",ret);
}
}
}
return ;
}

话说好几天没有写代码了的说啊----

加油↖(^ω^)↗

goooooooooooooooooo----

最新文章

  1. 使用angular.bootstrap() 完成模块的手动加载
  2. jquery怎么获取radio选中的值
  3. 在线音乐网站【03】Part one 功能实现
  4. 【Pro ASP.NET MVC 3 Framework】.学习笔记.8.SportsStore:管理
  5. 55.ERROR:Place:1136 - This design contains a global buffer instance…… non-clock load pins off chip
  6. Cassandra1.2文档学习(1)——Cassandra基本说明
  7. Win7新建ftp快捷方式(原XP网上邻居中客户端图标)
  8. 向着DJANGO奔跑!
  9. HA高可用的搭建
  10. perl学习(1) 入门
  11. 使用hexo搭建github博客
  12. app与后台交互之间的几种安全认证机制
  13. MySQL优化三(InnoDB优化)
  14. Java servlet ajax
  15. 点评阿里JAVA手册之MySQL数据库 (建表规约、索引规约、SQL语句、ORM映射)
  16. (cljs/run-at (JSVM. :all) &quot;一次说白DataType、Record和Protocol&quot;)
  17. python学习之数字
  18. 微软Azure云计算服务主导全球
  19. C#/.NET基于Topshelf创建Windows服务程序及服务的安装和卸载(极速,简洁)
  20. Java 使用blob对H5视频播放进行加密《java视频加密》

热门文章

  1. SQLSERVER 链接服务器执行存储过程
  2. CSS3背景 制作导航菜单综合练习题
  3. HTML5中canvas介绍
  4. tomcat 和 jboss的热部署(热发布)问题
  5. s2sh的MVC执行流程和执行原理
  6. 在centos上安装php5.5+MySQL 5.5.32
  7. day09-3 数据类型总结,深浅拷贝
  8. day08 数字,字符串类型内置方法
  9. Extjs toolbar 如何添加竖杆分隔符
  10. leetcode小题解析