Transmitters (simple ry)

Source: Internet
Author: User
Transmitters
Time limit:1000 ms   Memory limit:10000 K
Total submissions:4617   Accepted:2468

Question link: http://poj.org/problem? Id = 1106


Description

In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at least that they don't conflict. one way of accomplishing this is to restrict a transmitter's coverage area. this problem uses a shielded transmitter that only broadcasts in a semicircle.

A transmitter T is located somewhere on a 1,000 square meter grid. it broadcasts in a semicircular area of radius R. the transmitter may be rotated any amount, but not moved. given N points anywhere on the grid, compute the maximum number of points that can be simultaneously reached by the transmitter's signal. figure 1 shows the same data points with two different transmitter rotations.

All input coordinates are integers (0-1000 ). the radius is a positive real number greater than 0. points on the boundary of a semicircle are considered within that semicircle. there are 1-150 unique points to examine per transmitter. no points are 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 on 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 will be present but indeterminate. figures 1 and 2 represent the data in the first two example data sets below, though they are on different scales. figures 1A and 2 show transmitter rotations that result in maximal coverage.

Output

For each transmitter, the output contains a single line with the maximum number of points that can be contained in some semicircle.

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 998990 9921000 999100 100 -2.5

Sample output

344

Source

Mid-Central USA 2001

On a two-dimensional plane, there is a semi-circle and some points. The semi-circle can be rotated in any direction around the center and can contain a maximum of several points;

Meaning: first, sieve out the points falling out of the circle, put the points in the circle into the P array, and then sort the edges from small to large. Finally, determine a starting point and perform semi-circle, find the contained points;

AC code:
# Include <algorithm> # include <iostream> # include <cstdio> # include <cmath> using namespace STD; const int M = 500; const double Pi = ACOs (-1.0 ); double P [m]; const double EPS = 1e-8; double pow1 (double A, double B) {return (a-B) * (a-B );} double dist (double X1, double Y1, double X2, double Y2) {return pow1 (Y2, Y1) + pow1 (X2, X1);} double atan2 (double X1, double Y1, double X2, double Y2) {Double X = x2-x1; double Y = Y2-Y1; return atan2 (Y, x); // obtain the Polar Angle} int main () {// freopen ("in", "r", stdin ); double A, B, R, X, Y; while (~ Scanf ("% lf", & A, & B, & R) & R> EPS) {int M, to, Max; scanf ("% d", & M); To = max = 0; while (M --) {scanf ("% lf", & X, & Y ); if (Dist (X, Y, a, B)> r * r) continue; P [to ++] = atan2 (a, B, x, y ); if (P [to-1] <EPS) P [to-1] + = 2 * PI;} Sort (p, p + to); For (INT I =; I <to * 2; I ++) {P [I] = P [I-to] + 2 * PI; // facilitates the following processing ;} for (INT I = 0; I <to; I ++) {int T = 1; for (Int J = I + 1; j <to * 2; j ++) {double ang = P [J]-P [I]; If (ANG> PI) break; t ++;} max = max (max, T );} printf ("% d \ n", max);} return 0 ;}


Transmitters (simple ry)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.