• hdu1077


    #include<iostream>
    #include<cmath>
    using namespace std;

    struct Point
    {
    double x,y;
    };

    double dis_sq(const Point& a,const Point& b) //距离平方
    {
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
    }

    Point lock_center(const Point& a,const Point& b)
    {
    Point s,e,m;
    double d,c,ang;

    s.x=b.x-a.x; //用于计算角度
    s.y=b.y-a.y;
    m.x=(a.x+b.x)/2.0; //中点
    m.y=(a.y+b.y)/2.0;
    d=dis_sq(a,m);
    c=sqrt(1.0-d);
    if(fabs(s.y)<1e-8) //ab是直径
    {
    e.x=m.x;
    e.y=m.y+c;
    }
    else
    {
    ang=atan(-s.x/s.y); //求弦ab的垂直平分线与x轴所成的夹角
    e.x=m.x+c*cos(ang);
    e.y=m.y+c*sin(ang);
    }
    return e;
    }

    int main()
    {
    int T,n,i,j,k,ans,tmp;
    Point p[310],c;

    scanf("%d",&T);
    while(T--)
    {
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%lf%lf",&p[i].x,&p[i].y);
    ans=1; //一个点时为1种
    for(i=0;i<n-1;i++)
    for(j=i+1;j<n;j++)
    if(dis_sq(p[i],p[j])<=4.0) //平方
    {
    c=lock_center(p[i],p[j]);
    tmp=0;
    for(k=0;k<n;k++)
    if(sqrt(dis_sq(c,p[k]))<=1.0001)
    tmp++;
    if(ans<tmp)
    ans=tmp;
    }
    cout<<ans<<endl;
    }
    return 0;
    }

  • 相关阅读:
    LeetCode刷题191120
    LeetCode刷题191119
    LeetCode刷题191118
    LeetCode刷题191117
    Http相关小知识点笔记咯~
    Java开发之JSP指令
    Java开发之Servlet之间的跳转
    Java开发之Servlet生命周期
    Java开发之文件上传
    微信公众号开发之数据库
  • 原文地址:https://www.cnblogs.com/wangkun1993/p/6341633.html
Copyright © 2020-2023  润新知