"POJ 1981" Circle and Points

Source: Internet
Author: User

When the distance of two points is less than the diameter, a unit circle is determined by them for the chord (although there are two circles, but want to know that only one can) to calculate the coverage of how many points.

#include <cstdio> #include <cmath> #define N 301#define eps 1e-5using namespace std;int n,ans,tol;double X[n], Y[n],dx,dy;inline double Sqr (double x) {return x*x;} inline double dis (int a,int b) {return sqrt ((X[a]-x[b]) * (X[a]-x[b]) + (Y[a]-y[b]) * (Y[a]-y[b]));}    inline void Solve () {tol=0;    for (int i=1; i<=n; i++) if (DIS (0,i) <=1+eps) tol++; if (Tol>ans) ans=tol;} inline void get (int a,int b) {double V=atan ((X[b]-x[a])/(y[a]-y[b]);//equals 0 o'clock returns INF,V=PI/2 double c=sqrt (DIS (A, b    )/2.0));    dx= C*cos (v); dy= C*sin (v);}        int main () {while (scanf ("%d", &n) &&n) {Ans=1;        for (int i=1; i<=n; i++) scanf ("%lf%lf", &x[i],&y[i]); for (int i=1, i<=n; i++) for (int j=i+1; j<=n; J + +) if (DIS (i,j) <2) {Double m                X= (X[i]+x[j])/2.0,my= (Y[i]+y[j])/2.0;                Get (I,J);                X[0]=mx+dx,y[0]=my+dy;            Solve ();        }printf ("%d\n", ans); }}

  

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