Title Link: http://poj.org/problem?id=1106
Description
In a wireless network with multiple transmitters sending on the same frequencies, it's often a requirement that signals D On the ' t overlap, or at least that they don ' t conflict. One-of-the-accomplishing this is to restrict a transmitter's coverage area. This problem uses a shielded transmitter the only broadcasts in a semicircle.
A transmitter T is located somewhere on a square meter grid. IT broadcasts in a semicircular area of radius R. The transmitter is rotated any amount and not moved. Given N points anywhere on the grid, compute the maximum number of points that can is simultaneously reached by the TRANSM Itter ' s signal. Figure 1 shows the same data points with the different transmitter rotations.
All input coordinates is integers (0-1000). The radius is a positive real number greater than 0. Points on the boundary of a semicircle is considered within that semicircle. There is 1-150 unique points to examine per transmitter. No points is at the same location as the transmitter.
Input
Input consists of information for one or more independent transmitter problems. Each problem begins with one line containing the (x, y) coordinates of the transmitter followed by the broadcast radius, R. The next line contains the number of points N in the grid, followed by N sets of (x, y) coordinates, one set per line. The end of the input is signalled by a line with a negative radius; The (x, Y) values are present but indeterminate. Figures 1 and 2 represent the data in the first and example data sets below, though they is on different scales. Figures 1a and 2 show transmitter rotations This result in maximal coverage.
Output
For each transmitter, the output contains a, a, and the maximum number of points that can is contained in some SE Micircle.
Sample Input
25 25 3.5725 2823 2727 2724 2326 2324 2926 29350 200 2.05350 202350 199350 198348 200352 200995 995 10.041000 1000999 9989 90 9921000 999100 100-2.5
Sample Output
344
Source
Mid-Central USA 2001
Test instructions
Given some points, and a center coordinate and radius, to find a semi-circle can be up to how many points, semicircle can be rotated around the center.
Ps:
Just take into account those points where the center distance is less than or equal to the radius.
Place all qualifying points in an array tt[],
Then the double loop enumerates the number of points (cross product) of each point to the left of the line connected to the center of the circle.
Record The maximum value can be.
cross product, dot product: http://blog.csdn.net/y990041769/article/details/38258761
The code is as follows:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include < Cmath>using namespace Std;struct node{double x, y;} p[100017],tt[100017];d ouble Cross (node A,node b,node C)//Fork Product { Return (b.x-a.x) * (C.Y-A.Y)-(B.Y-A.Y) * (c.x-a.x);} Double Dis (node A,node B)//Distance {return (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y);} int main () {double R; Node C; while (~SCANF ("%lf%lf%lf", &c.x,&c.y,&r)) {if (R < 0) {break; } int n; scanf ("%d", &n); int k = 0; for (int i = 0; i < n; i++) {scanf ("%lf%lf", &p[i].x,&p[i].y); Double d = dis (c,p[i]); if (d <= r*r) {tt[k].x = p[i].x; Tt[k].y = P[I].Y; k++; }} int ansmax = 0; for (int i = 0; i < K; i++) {int cont = 1; for (int j = 0; J < K; J + +) {if (i!= J && Cross (C,tt[i],tt[j]) >=0) {cont++; }} if (cont > Ansmax) {ansmax = cont; }} printf ("%d\n", Ansmax); } return 0;}
POJ transmitters (Calculate geometric polar angle sorting AH)