POJ - 2029 Get Many Persimmon Trees(暴力水题)
发布日期:2021-10-03 15:44:42 浏览次数:2 分类:技术文章

本文共 839 字,大约阅读时间需要 2 分钟。

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

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

#include 
#include
#include
using namespace std;const int N = 110;int n, w, h, s, t;int map[N][N];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;}

转载地址:https://blog.csdn.net/L123012013048/article/details/48860695 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:HDU - 2713 Jumping Cows(DP水题)
下一篇:HDU - 1200 To and Fro(水)

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月11日 10时18分02秒