poj 2029 (暴力枚举)水题
来源:互联网 发布:舔女生尿道口 知乎 编辑:程序博客网 时间:2024/05/16 12:22
暴力,枚举从位置map[i][j]到map[i+S-1][j+T-1]的局域和,求出最大的就ok了~
代码如下:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define MAX 111int map[MAX][MAX],sum[MAX][MAX];int N,S,T,W,H;int x,y;int ans;int calsum(int x1,int y1,int x2,int y2){ return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];}void input(){ int i,j; memset(map,0,sizeof(map)); scanf("%d%d",&W,&H); for(i=1;i<=N;i++) { scanf("%d%d",&x,&y); map[x][y]=1; } scanf("%d%d",&S,&T);}void deal(){ int i,j; for(i=1;i<=W;i++) { for(j=1;j<=H;j++) { sum[i][j]=sum[i-1][j]+sum[i][j-1]+map[i][j]-sum[i-1][j-1]; } }}void work(){ int i,j; ans=0; for(i=1;i+S-1<=W;i++) { for(j=1;j+T-1<=H;j++) { ans=max(ans,calsum(i,j,i+S-1,j+T-1)); } } printf("%d\n",ans);}int main(){ int i,j; while(scanf("%d",&N),N) { input(); deal(); work(); } return 0;}
0 0
- poj 2029 (暴力枚举)水题
- poj 3671(暴力 枚举)
- Tautology(POJ 3295)(暴力枚举)
- POJ 3279 (状态压缩暴力枚举)
- POJ:2718 Smallest Difference(暴力枚举)
- poj 3102(暴力枚举)
- POJ 2718 暴力枚举
- POJ-----3279暴力枚举
- POJ 3174 暴力枚举
- poj 3080 暴力法 KMP+暴力枚举
- poj 1248 Safecracker(暴力枚举)
- POJ 1068 Parencodings(暴力枚举)
- POJ-2078 Matrix,暴力枚举!
- poj 2029 Get Many Persimmon Trees 暴力枚举
- POJ 1050 To the Max (最大连续区间和+暴力枚举,水题)
- POJ 3279 Fliptile (暴力枚举)(D)
- poj 2109 Power of Cryptography(暴力枚举)
- POJ 1753 Flip Game 暴力搜索(dfs加枚举)
- poj2080!【水题】
- 从先序遍历和中序遍历重建二叉树
- 再试一下,看是否好用
- poj 2594 二分图 Floyd闭包+最小路径覆盖
- Dom解析XML文件具体用法
- poj 2029 (暴力枚举)水题
- 操作系统虚拟化底层基础之命名空间(namespace)
- 51416/D辛苦屎了,骗纸呐o o
- 网页设计用目标的好处
- 一个setInterval的小问题
- python学习二
- JSP中response.sendRedirect()后的代码为什么还能执行
- 编程之美--3.5最短摘要的生成
- DEV控件:gridControl常用属性设置