poj 2029 && zoj 1716 Get Many Persimmon Trees
来源:互联网 发布:沈阳seo 公司 编辑:程序博客网 时间:2024/05/22 08:05
树状数组的题目,暴力水过。但是,我表示对树状数组理解的还不是很清楚。尤其是在更新值的时候,为啥有时候就要再原来的值上加1,有时候就不加。很多的东西都需要仔细的体会,真是..TT...不说了!
#include<stdio.h>#include<iostream>#include<string.h>using namespace std;#define N 130int c[N][N];int n,m;int lowbit(int x){ return x&(-x);}void Updata(int x,int y){ for(int i=x;i<=N;i+=lowbit(i)) { for(int j=y;j<=N;j+=lowbit(j)) { c[i][j]++; } }}int Getsum(int x,int y){ int sum=0; for(int i=x;i>0;i-=lowbit(i)) { for(int j=y;j>0;j-=lowbit(j)) { sum+=c[i][j]; } } return sum;}int main(){ int cnt; int x,y,x1,y1; while(scanf("%d",&cnt)&&cnt) { scanf("%d%d",&n,&m); memset(c,0,sizeof(c)); while(cnt--) { scanf("%d%d",&x,&y); Updata(x,y); } scanf("%d%d",&x1,&y1); int max=0; for(int i=x1;i<=n;i++) { for(int j=y1;j<=m;j++) { int ans=Getsum(i,j)-Getsum(i-x1,j)-Getsum(i,j-y1)+Getsum(i-x1,j-y1); if(max<ans)max=ans; } } printf("%d\n",max); } return 0;}
- zoj 1716 || poj 2029 Get Many Persimmon Trees
- poj 2029 && zoj 1716 Get Many Persimmon Trees
- POJ 2029 && ZOJ 1716 Get Many Persimmon Trees
- zoj 1716 Get Many Persimmon Trees
- ZOJ 1716 Get Many Persimmon Trees (暴力)
- POJ 2029 Get Many Persimmon Trees
- Poj 2029 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees [dp]
- POJ 2029 Get Many Persimmon Trees (标记)
- POJ 2029 Get Many Persimmon Trees
- poj-2029-Get Many Persimmon Trees-预处理
- POJ 2029 Get Many Persimmon Trees
- poj 2029 Get Many Persimmon Trees
- poj 2029 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees
- POJ 2029--Get Many Persimmon Trees +DP
- poj 2029 Get Many Persimmon Trees
- WAP1.x协议栈浅析-WSP协议
- 【转】Struts2的注解功能
- 通过单臂路由实现两个vlan的互访
- 搜索引擎大换血,SEO的“星晴”也在大换血
- Eclipse常用快捷键大全(三)
- poj 2029 && zoj 1716 Get Many Persimmon Trees
- 数组基础
- Eclipse常用快捷键大全(四)
- 暴风影音2011 去广告补丁V1.1
- Java 7 新特性 -- 实战篇
- C# .Net 学习积累《五》
- 【转】Spring 注解
- 关于Android隐式启动Activity
- Easy RadControl 之 RadTabControl(Silverlight)