思路:从一维扩展到三维。可以看看poj2155的解法。

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#define Maxn 102
#define lowbit(x) (x&(-x))
using namespace std;
int C[Maxn][Maxn][Maxn],n;
int Sum(int i,int j,int k)
{
int sum=;
int y,z;
y=j,z=k;
while(i)
{
j=y;
while(j)
{
k=z;
while(k)
{
sum+=C[i][j][k];
k-=lowbit(k);
}
j-=lowbit(j);
}
i-=lowbit(i);
}
return sum;
}
void update(int i,int j,int k)
{
int y,z;
y=j,z=k;
while(i<=n)
{
j=y;
while(j<=n)
{
k=z;
while(k<=n)
{
C[i][j][k]++;
k+=lowbit(k);
}
j+=lowbit(j);
}
i+=lowbit(i);
}
}
int main()
{
int x1,x2,y1,y2,z1,z2,m,x;
while(scanf("%d%d",&n,&m)!=EOF)
{
memset(C,,sizeof(C));
while(m--)
{
scanf("%d",&x);
if(x==)
{
scanf("%d%d%d",&x1,&y1,&z1);
printf("%d\n",Sum(x1,y1,z1)&);
}
if(x==)
{
scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2);
update(x1,y1,z1);
update(x1,y2+,z1);
update(x2+,y2+,z1);
update(x2+,y1,z1);
update(x1,y1,z2+);
update(x1,y2+,z2+);
update(x2+,y2+,z2+);
update(x2+,y1,z2+);
}
}
}
return ;
}

最新文章

  1. Python 学习第十八天 js 正则及其它前端知识
  2. python使用xlrd模块读写excel
  3. CSS hack的写法
  4. IIS6批量转移网站
  5. 文件IO 练习题
  6. git+Coding.netの小试牛刀
  7. 关于struts2中的default-action-ref
  8. mac sourcetree启用外部合并工具(beyond compare)
  9. View Components as Tag Helpers,离在线模板编辑又进一步
  10. JavaScript基础知识(二)
  11. Winform退出运行后,删除运行目录(批处理方法)
  12. listbox控件使用
  13. BZOJ 1029: [JSOI2007]建筑抢修【优先队列+贪心策略】
  14. 前端开发之基础知识-HTML(二)
  15. spark的运行模式
  16. 详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON()【转】【补】
  17. Mysql 多表查询详解
  18. 数据库并发事务控制四:postgresql数据库的锁机制二:表锁 &lt;转&gt;
  19. onvif协议client与server对接
  20. (21)python Anaconda

热门文章

  1. HDU 5813 Elegant Construction (贪心)
  2. CodeForces 455A Boredom (DP)
  3. maven系列(3)-maven生命周期的介绍
  4. CodeForces 560B Gerald is into Art
  5. mongod的主要参数解释
  6. WEB安全之威胁解析
  7. no datanode to stop
  8. [置顶] stax解析xml文档的6种方式
  9. C++ 内存相关
  10. IOS 7 开发范例 - UISwitch的使用