zoj 1716 Get Many Persimmon Trees
2012-04-01 10:41
477 查看
//这题主要是给定一个矩形的宽度和高度,在给出的这个矩形的面积中, //求出包含最多的树的数目,最开始WA了很多次,因为没有考虑到取值的范围! //下面主要用枚举的方法,一个一个的矩形进行枚举! #include "iostream" #include "memory.h" #include "algorithm" using namespace std; struct treespos { int width; int height; }; int main() { int treesnum, i, j, k, width, height, x, y, tempx, tempy, count; treespos pos[10001];//树木的坐标,由于之前开数组开小了,WA了一次! int ans[10001];//统计每一个矩形中包含树的数目! while (cin >> treesnum && treesnum) { cin >> width >> height; for (i = 0; i < treesnum; i++) cin >> pos[i].width >> pos[i].height; cin >> x >> y; memset(ans, 0, sizeof(ans)); count = 0; for(i = 1; i <= width - x + 1; i++)//进行枚举,注意取值的范围,不要越界! for (j = 1; j <= height - y + 1; j++) { tempx = x+i-1; tempy = y+j-1; for(k = 0; k < treesnum; k++) { if (pos[k].width >= i && pos[k].width <= tempx && pos[k].height <= tempy && pos[k].height >= j) ans[count]++; } count++; } sort(ans, ans+10001); cout << ans[10000] << endl; } }
相关文章推荐
- ZOJ 1716 Get Many Persimmon Trees (暴力)
- zoj1716 Get Many Persimmon Trees
- zoj1716 Get Many Persimmon Trees
- zoj 1716 || poj 2029 Get Many Persimmon Trees
- POJ 2029 && ZOJ 1716 Get Many Persimmon Trees
- poj 2029 && zoj 1716 Get Many Persimmon Trees
- POJ 2029 && ZOJ 1716 Get Many Persimmon Trees
- POJ2029--Get Many Persimmon Trees
- poj 2029 Get Many Persimmon Trees
- poj 2029 Get Many Persimmon Trees (dp)
- poj 2029 Get Many Persimmon Trees
- xtu数据结构 B. Get Many Persimmon Trees
- POJ 2029 Get Many Persimmon Trees(二维树状数组)
- poj2029 Get Many Persimmon Trees
- poj 2029 Get Many Persimmon Trees
- POJ_2029_GetManyPersimmonTrees
- 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