Input the first line to give the center coordinates and radius of a circle, and then give n points. It is required to take out a semicircle in this circle, so that the semicircle covers the most points, and output the maximum number of points.
example input
The first line: the coordinates of the center of the circle and the radius of the circle
The second line: the number of points n
n lines after the second line: the coordinates of each point
There are several sets of input test data, the end mark of the input test data, input the coordinates of the center of a circle, and the radius is a negative number
For n points of each set of test data, it is only necessary to keep the points within the circle, because the points not within the circle cannot be within the semicircle, and invalid points are excluded to avoid invalid judgments
Since it is impossible for us to enumerate all the angles of the semicircle, because all the angles of the semicircle are infinitely many, that is, there are infinitely many ways to place the semicircle, so we should consider which ways to place the semicircle are useful.
In fact, we only need to enumerate the cases where the diameter of the semicircle coincides with any point in the circle, that is, to enumerate all possible cases where any point in the circle is on the diameter of the semicircle, the placement of the semicircle, because the optimal The semicircle must be just stuck on a point, so that enough space can be left for other points, so that the number of points in the semicircle is the largest .
So we only need to violently enumerate the boundary (any point in the circle is on the diameter), and then use the cross product to count the number of points in the semicircle under this placement, and finally take the maximum value from all possible cases. Can
When calculating, the diameter vector takes the representation of the center of the circle pointing to the point on the diameter inside the circle, and the semicircle is on the left side of the diameter
Therefore, the cross product with the radius vector is greater than or equal to 0 (counterclockwise), in the semicircle; otherwise not in the semicircle (clockwise)
I don’t know why the uppercase and lowercase n of the array is created dynamically, and a compilation exception will be reported in POJ, so the size of the array is directly measured in literals.