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, so an island in the sea can be covered by a radius installation, if the distance between them is at most d.
假设海岸线是一条无限长的直线。陆地在海岸线的一边,海洋在另一边。每个小岛都是位于海边的一个点。而任何位于海岸上的雷达装置只能覆盖d距离,因此,如果它们之间的距离不超过d,那么海上的岛屿可以被半径装置覆盖。
We use Cartesian coordinate system, defining the coasting is the x-axis. The sea side is above x-axis, and the land side below. Given the position of each island in the sea, and given the distance of the coverage of the radar installation, your task is to write a program to find the minimal number of radar installations to cover all the islands. Note that the position of an island is represented by its x-y coordinates.
我们使用笛卡尔坐标系,将海岸线定义为x轴。海侧在x轴上方,陆侧在x轴下方。考虑到每个岛屿在海上的位置,以及雷达装置的覆盖距离,您的任务是编写一个程序,以找到覆盖所有岛屿的雷达装置的最小数量。请注意,岛的位置由其x-y坐标表示。
Figure A Sample Input of Radar Installations
输入:
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 lines each containing two integers representing the coordinate of the position of each island. Then a blank line follows to separate the cases.
The input is terminated by a line containing pair of zeros
For each test case output one line consisting of the test case number followed by the minimal number of radar installations needed. "-1" installation means no solution for that case.
对于每个测试用例输出,一行由测试用例编号和所需的最小雷达安装数量组成。“-1”安装意味着在这种情况下没有解决方案。