POJ 1981 Circle and Points

Source: Internet
Author: User

For any point already covered some points of the circle, can be offset by the circle, so that it is guaranteed to cover the point on the basis of covering more points//to this offset to the limit, that is, just make two points in the circle//In fact, the idea of this problem and POJ1106 is similar, but see the scope of the party in the [ 0,10] Think of random algorithm go//There is also a n^2logn practice, learn the circle on the arc is covered by the number of marks #include<stdio.h> #include <algorithm> #include < Math.h>using namespace Std;const Double eps=1e-8;struct point {double X, y;};    struct node{double angle; int in;}; Node arc[1005]; Point p[305];d ouble Dist (Point p,point q) {return sqrt ((p.x-q.x) * (p.x-q.x) + (P.Y-Q.Y) * (P.Y-Q.Y));}    int cmp (Node A,node b) {if (A.angle!=b.angle) return a.angle<b.angle; else return a.in>b.in;}    int main () {#ifndef Online_judge freopen ("In.txt", "R", stdin);    #endif//Online_judge int n;        while (scanf ("%d", &n), n) {int ans=1;        for (int i=0;i<n;i++) scanf ("%lf%lf", &p[i].x,&p[i].y);            for (int i=0;i<n;i++) {int cnt=0;                for (int j=0;j<n;j++) {if (i==j) continue;                if (Dist (p[i],p[j]) >2.0+eps) continue; Double B=atan2 (p[j].y-p[i].y,p[j].x-p[i].x];                Double A=acos (Dist (p[i],p[j])/2); Arc[cnt].angle=b-a; Arc[cnt++].in=1; The point with the small angle as the point of entry arc[cnt].angle=b+a;            Arc[cnt++].in=-1;            } sort (arc,arc+cnt,cmp);            int tmp=1;                for (int j=0;j<cnt;j++) {//if (arc[j].in) tmp++; if is also set if the value is negative (as long as the non-0 is established) tmp+=arc[j].in;            Ans=max (ANS,TMP);    }} printf ("%d\n", ans); } return 0;}

POJ 1981 Circle and Points

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.