POJ - 2029 Get Many Persimmon Trees(暴力水题)
2015-10-02 15:47
405 查看
题目大意:给你一个矩阵,矩阵上面有N个柿子树,现在要求你画一个s*t的矩阵,使得这个矩阵内的柿子树达到最多
解题思路:100 * 100,直接暴力
解题思路: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; }
相关文章推荐
- Android控件布局属性全解
- DirectX11 骷髅头示例Demo
- EIP和目标地址的关系
- UVA 11177 凸多边形和圆交
- 查找二叉树
- SQL常用命令
- HDU - 1200 To and Fro(水)
- 数据库的优化
- 枚举类型的基本用法
- Matlab基础知识
- Extjs4.2 model关联读复杂XML
- 面试题22:栈的压入、弹出序列
- vfork http://blog.csdn.net/tennysonsky/article/details/45847107
- BZOJ 3531 旅行【树链剖分】
- 数据库最最常用语句(10年工作笔记)
- java抽象类
- 如何在Linux上使用netstat命令查证DDOS攻击
- android布局属性大全
- 安卓控件使用系列12:CheckBox复选框控件的使用
- 轮廓线动态规划问题