poj 2029 Get Many Persimmon Trees 暴力枚举
2014-12-06 14:19
387 查看
题意:
给n个点和一个宽w高h的矩形,求该矩形最多能框住多少个点。
分析:
O^2算法直接暴力枚举放置矩形右上角的点。
代码:
给n个点和一个宽w高h的矩形,求该矩形最多能框住多少个点。
分析:
O^2算法直接暴力枚举放置矩形右上角的点。
代码:
//poj 2029 //sep9 #include<iostream> using namespace std; int map[128][128]; int main() { int i,j,n,w,h,s,t; while(scanf("%d",&n)==1&&n){ memset(map,0,sizeof(map)); scanf("%d%d",&w,&h); while(n--){ scanf("%d%d",&i,&j); map[i][j]=1; } scanf("%d%d",&s,&t); for(i=1;i<=w;++i) for(j=1;j<=h;++j) map[i][j]+=map[i-1][j]+map[i][j-1]-map[i-1][j-1]; int ans=0; for(i=s;i<=w;++i) for(j=t;j<=h;++j) ans=max(ans,map[i][j]-map[i-s][j]-map[i][j-t]+map[i-s][j-t]); printf("%d\n",ans); } return 0; }
相关文章推荐
- 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 (标记)
- zoj 1716 || 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 && ZOJ 1716 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
- POJ 2029 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees(二维树状数组)
- POJ 2029 && ZOJ 1716 Get Many Persimmon Trees