zoukankan      html  css  js  c++  java
  • CodeForces 617C Watering Flowers

    无脑暴力题,算出所有点到圆心p1的距离的平方,从小到大排序。

    然后暴力枚举p1的半径的平方,计算剩余点中到p2的最大距离的平方,枚举过程中记录答案

    #include<cstdio>
    #include<cstring>
    #include<vector>
    #include<cmath>
    #include<queue>
    #include<list>
    #include<algorithm>
    using namespace std;
    
    const int maxn=2000+10;
    struct point
    {
        long long x,y;
        long long len2;//与圆心p1的距离的平方
    }p[maxn],p1,p2;
    int n;
    
    long long Len2(point a,point b)
    {
        return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
    }
    
    bool cmp(const point&a,const point&b)
    {
        return a.len2<b.len2;
    }
    
    int main()
    {
        scanf("%d",&n);
        scanf("%lld%lld",&p1.x,&p1.y);
        scanf("%lld%lld",&p2.x,&p2.y);
    
        for(int i=0;i<n;i++) scanf("%lld%lld",&p[i].x,&p[i].y);
        for(int i=0;i<n;i++) p[i].len2=Len2(p1,p[i]);
    
        long long ans=-1;
        sort(p,p+n,cmp);
    
        for(int i=0;i<n;i++)
        {
            long long Max=0;
            for(int j=i+1;j<n;j++)
                Max=max(Max,Len2(p2,p[j]));
            if(ans==-1) ans=Max+p[i].len2;
            else ans=min(ans,Max+p[i].len2);
        }
        long long Max=0;
        for(int i=0;i<n;i++)
            Max=max(Max,Len2(p2,p[i]));
        ans=min(ans,Max);
        printf("%lld
    ",ans);
        return 0;
    }
  • 相关阅读:
    docker中查看Jenkins administrator密码
    Http缓存机制
    Jenkins启动的两种方式
    git上传项目命令方式
    windows系统.ssh文件夹脚本创建id_rsa和id_rsa.pub
    python日期加减操作
    python xlrd
    断言框架
    接口测试工具
    fake stub mock
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5156679.html
Copyright © 2011-2022 走看看