Zoj 1041 Transmitters determine the maximum number of points that can be moved by a semicircle

Source: Internet
Author: User

Source of the topic:

Http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=41

Test instructions: Determines the maximum number of points that can be moved by a semicircle.

Analysis: Calculate the points within the circle, and then enumerate the points, the points and the center of the line of the diameter of the left and right points of the statistics, the maximum can be.

The code is as follows:

Const DoubleEPS = 1e- A;Const intMax_n = the;DoubleAddDoubleADoubleb) {    return(Fabs (A + B) < EPS * (Fabs (a) + fabs (b)))?0: (A +b);}structpoint{Doublex, y; Point () {}, point (DoubleXDoubley): x (x), Y (y) {}DoubleDist (point P) {returnsqrt (Add (x-p.x) * (x-p.x), (y-p.y) * (Y-( p.y))); } Pointoperator-(point P) {returnPoint (Add (x,-p.x), add (Y,-p.y)); }    Double operator^(point P) {returnAdd (x * p. y,-y *p.x); }}po[max_n]; Point ro;DoubleR;intMain () {intN, I, J, Maxm;  while(SCANF ("%LF%LF%LF", &ro.x, &ro.y, &r) && r >0) {MAXM=0 ; scanf ("%d", &N);  for(i =0; I < n; i++) scanf ("%LF%LF", &po[i].x,&po[i].y); intL =0 ;  for(i =0; i< N; i++)            if(Ro.dist (Po[i])-R <=EPS) Po[l++] =Po[i]; N=l; intLeft , right;  for(i =0; I < n; i++) { left=0, right =0;  for(j =0; j< N; J + +){                    DoubleD = (Po[i]-ro) ^ (Po[j]-ro); if(D >0) Left + + ; Else if(D <0) Right + + ; Else{ Left++ ; Right++ ; }} MAXM= Maxm < left?LEFT:MAXM; MAXM= Maxm < right?RIGHT:MAXM; } printf ("%d\n", MAXM); }    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.