Zju 1041 transmitters solution report

Source: Internet
Author: User

Question:

Transmitters

Crawling in process...Crawling failedTime
Limit:
1000 msMemory limit:10000kb
64bit Io format:% I64d & % i64u

Submitstatus

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
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

 

 

Enter multiple vertices in the coordinate system and use a semi-circle to remove the vertices to find the number of vertices with the largest number of covers.

Idea: when the input point is used, determine whether the point is in the circle with the radius of the half circle. Then enumerate the line between each vertex and the center of the circle, and use the cross product to determine which side of the other vertex is in this line. (The knowledge of cross product can be seen in the code comment)

 

AC code:

# Include <iostream> using namespace STD; int main () {int X, Y; Double R; while (CIN> x> Y> r & R> 0) {int max = 0, I, j = 0, N; Double A, B, P [1005] [2]; // P indicates point coordinate CIN> N; for (I = 0; I <n; I ++) {CIN> A> B; If (a-x) * (a-x) + (B-y) * (B-y) <= r * r) // determines whether the vertex is in the circle {P [J] [0] =; P [J ++] [1] = B ;}} for (I = 0; I <j; I ++) {a = B = 0; for (int K = 0; k <j; k ++) {int q = (P [I] [0]-x) * (p [k] [1]-y)-(P [k] [0]-x) * (p [I] [1]-y ); // use the cross product to determine if (q> 0) // q> 0 points in the reverse clock direction of the straight line + + A; else if (q = 0) // q = 0 Points + + B on a straight line;} A = A> J-B-? A: J-B-a; // here you can easily understand (consider online points) if (max <a + B) max = a + B ;} cout <max <Endl;} return 0 ;}

 

 

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.