fzuoj1111Radar Installation (贪心)】的更多相关文章

题目大意是在海岸线布置n个雷达,要求雷达的范围要包含所有的小岛: 思路:逆向思维把小岛看成一个个范围,与海岸线的交集,从最左端的开始找 (贪心最左端的点),接着不用一个一个去遍历,直接用前一个的右端点去替换下一个的左端点....直至最后一个点.大致思想就是贪心,还是比较正常的题,适合刚学c语言的新生做(小白我就是一枚). 下面是代码: #include <iostream> #include <cmath> #include <algorithm> #include &…
POJ 1328 Radar Installation https://vjudge.net/problem/POJ-1328 题目: Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation…
Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64472   Accepted: 14497 Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point loca…
Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 56826   Accepted: 12814 Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point loca…
Language: Default Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42461   Accepted: 9409 Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small islan…
题目链接. 题意: 给定一坐标系,要求将所有 x轴 上面的所有点,用圆心在 x轴, 半径为 d 的圆盖住.求最少使用圆的数量. 分析: 贪心. 首先把所有点 x 坐标排序, 对于每一个点,求出能够满足的 最靠右的圆心,即雷达的位置. 要保证雷达左面的点都被覆盖,如果不能覆盖就向左移,移到能将左边未覆盖的覆盖.如果后面的店不在雷达的覆盖区,则再加一雷达. #include <iostream> #include <cstdio> #include <cstdlib> #i…
Radar Installation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Total Submission(s) : 54   Accepted Submission(s) : 28 Problem Description Assume the coasting is an infinite straight line. Land is in one side of co…
Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, s…
Input The input consists of several test cases. The first line of each case contains two integers n (1<=n<=1000) and d, where n is the number of islands in the sea and d is the distance of coverage of the radar installation. This is followed by n li…
题目链接:http://poj.org/problem?id=1328 题解:区间选点类的题目,求用最少的点以使得每个范围都有点存在.以每个点为圆心,r0为半径,作圆.在x轴上的弦即为雷达可放置的范围.这个范围可用勾股定理求得.记录每个点的范围,然后排序,贪心. (由于不熟悉qsort的用法,折腾了一个小时.后来清晰了:qsort 的cmp是通过正负判断(但结构体又不是),而sort的cmp是通过对错判断,即0或1.所以qsort的cmp用‘-’(结构体除外),sort的cmp用‘<’和‘>’…