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

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

#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<list>
#include<algorithm>
using namespace std; const int maxn=+;
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=;i<n;i++) scanf("%lld%lld",&p[i].x,&p[i].y);
for(int i=;i<n;i++) p[i].len2=Len2(p1,p[i]); long long ans=-;
sort(p,p+n,cmp); for(int i=;i<n;i++)
{
long long Max=;
for(int j=i+;j<n;j++)
Max=max(Max,Len2(p2,p[j]));
if(ans==-) ans=Max+p[i].len2;
else ans=min(ans,Max+p[i].len2);
}
long long Max=;
for(int i=;i<n;i++)
Max=max(Max,Len2(p2,p[i]));
ans=min(ans,Max);
printf("%lld\n",ans);
return ;
}

CodeForces 617C Watering Flowers的更多相关文章

  1. Codeforces Round #340 (Div. 2) C. Watering Flowers 暴力

    C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerb ...

  2. 「日常训练」Watering Flowers(Codeforces Round #340 Div.2 C)

    题意与分析 (CodeForces 617C) 题意是这样的:一个花圃中有若干花和两个喷泉,你可以调节水的压力使得两个喷泉各自分别以\(r_1\)和\(r_2\)为最远距离向外喷水.你需要调整\(r_ ...

  3. cf340 C. Watering Flowers

    C. Watering Flowers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #340 Watering Flowers

    题目: http://www.codeforces.com/contest/617/problem/C 自己感觉是挺有新意的一个题目, 乍一看挺难得(= =). 其实比较容易想到的一个笨办法就是:分别 ...

  5. CodeForces 617C【序枚举】

    题意: 有两个点喷水,有很多个点有花,给出坐标. 求使得每个花都可以被喷到,两个喷水的半径的平方的和最小是多少. 思路: 枚举其中一个喷水的最大半径. 坑: 这题我贪心的思路有很大问题.一开始也是想这 ...

  6. CodeForces 474.D Flowers

    题意: 有n朵花排成一排,小明要么吃掉连续的k朵白花,或者可以吃单个的红花. 给出一个n的区间[a, b],输出总吃花的方法数模 109+7 的值. 分析: 设d(i)表示吃i朵花的方案数. 则有如下 ...

  7. 【Codeforces 474D】Flowers

    [链接] 我是链接,点我呀:) [题意] 让你吃东西 B食物一次必须要吃连续k个 但是对A食物没有要求 问你有多少种吃n个食物的方法(吃的序列) [题解] 设f[i]表示长度为i的吃的序列且符合要求的 ...

  8. [Codeforces Round #340 (Div. 2)]

    [Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...

  9. Codeforces 451E Devu and Flowers(容斥原理)

    题目链接:Codeforces 451E Devu and Flowers 题目大意:有n个花坛.要选s支花,每一个花坛有f[i]支花.同一个花坛的花颜色同样,不同花坛的花颜色不同,问说能够有多少种组 ...

随机推荐

  1. android把图片 视频 保存到相册

    //android把图片文件添加到相册 ContentResolver localContentResolver = getContentResolver(); ContentValues local ...

  2. SQL SERVER中强制类型转换cast和convert的区别

    在SQL SERVER中,cast和convert函数都可用于类型转换,其功能是相同的, 只是语法不同. cast一般更容易使用,convert的优点是可以格式化日期和数值. 代码 select CO ...

  3. coco2d-x CCDirector.h文件中变量*m_pNotificationNode*

    1.在CCDiretor.h中有如下说明 /** This object will be visited after the main scene is visited. This object MU ...

  4. 689D Friends and Subsequences RMQ+二分

    题目大意:给出两个数组,求第一个数组区间内的最大值和第二个区间内的最小值相同的区间有多少种. 题目思路:通过预处理(O(n*Logn))后,每次查询的时间复杂度为O(1),但是如果暴力查询O(n*n) ...

  5. CodeForces 510B DFS水题

    题目大意:在图中找到一个字符可以围成一个环(至少有环四个相同元素) 题目思路:对当前点进行搜索,如果发现可以达到某个已经被查找过的点,且当前点不是由这个点而来,则查找成功. #include<c ...

  6. 关于cin.getline和cin.get

    <C++ Primer Plus(第六版)> P124 第8题 #include <iostream> using namespace std;   struct Pizza ...

  7. Tinyxml封装类COperatorXml

    OperatorXml.h头文件 #ifndef _OPERATOR_XML_H_ #define _OPERATOR_XML_H_ #include <string> class TiX ...

  8. SCRIPT7002: XMLHttpRequest: 网络错误 0x2ef3, 由于出现错误 00002ef3&nbsp

    项目使用的是tomcat7 ,浏览器是ie11 突然打开浏览器发现不能获取数据了 tomcat conf server.xml 文件 <Connector port="8080&quo ...

  9. 推荐 iOS 网站:

    0. https://developer.apple.com/videos/1. http://www.raywenderlich.com2. http://nshipster.com3. http: ...

  10. Java 向Hbase表插入数据报(org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac

    org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac 代码: //1.create HTa ...