您的位置:首页 > 其它

POJ - 2029 Get Many Persimmon Trees(暴力水题)

2015-10-02 15:47 405 查看
题目大意:给你一个矩阵,矩阵上面有N个柿子树,现在要求你画一个s*t的矩阵,使得这个矩阵内的柿子树达到最多

解题思路:100 * 100,直接暴力

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;

int n, w, h, s, t;
int map

;

void init() {
scanf("%d%d", &w, &h);
memset(map, 0, sizeof(map));

int x, y;
for (int i = 0; i < n; i++) {
scanf("%d%d", &x, &y);
map[x][y] = 1;
}
scanf("%d%d", &s, &t);
}

void solve() {
int ans = 0;

for (int i = 1; i + s - 1 <= w; i++)
for (int j = 1; j + t - 1 <= h; j++) {
int cnt = 0;
for (int k = i; k < i + s; k++)
for (int l = j; l < j + t; l++)
if (map[k][l]) cnt++;
ans = max(cnt, ans);
}
printf("%d\n", ans);
}

int main() {
while (scanf("%d", &n) != EOF && n) {
init();
solve();
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: