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=+;
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的更多相关文章
- Codeforces Round #340 (Div. 2) C. Watering Flowers 暴力
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerb ...
- 「日常训练」Watering Flowers(Codeforces Round #340 Div.2 C)
题意与分析 (CodeForces 617C) 题意是这样的:一个花圃中有若干花和两个喷泉,你可以调节水的压力使得两个喷泉各自分别以\(r_1\)和\(r_2\)为最远距离向外喷水.你需要调整\(r_ ...
- cf340 C. Watering Flowers
C. Watering Flowers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #340 Watering Flowers
题目: http://www.codeforces.com/contest/617/problem/C 自己感觉是挺有新意的一个题目, 乍一看挺难得(= =). 其实比较容易想到的一个笨办法就是:分别 ...
- CodeForces 617C【序枚举】
题意: 有两个点喷水,有很多个点有花,给出坐标. 求使得每个花都可以被喷到,两个喷水的半径的平方的和最小是多少. 思路: 枚举其中一个喷水的最大半径. 坑: 这题我贪心的思路有很大问题.一开始也是想这 ...
- CodeForces 474.D Flowers
题意: 有n朵花排成一排,小明要么吃掉连续的k朵白花,或者可以吃单个的红花. 给出一个n的区间[a, b],输出总吃花的方法数模 109+7 的值. 分析: 设d(i)表示吃i朵花的方案数. 则有如下 ...
- 【Codeforces 474D】Flowers
[链接] 我是链接,点我呀:) [题意] 让你吃东西 B食物一次必须要吃连续k个 但是对A食物没有要求 问你有多少种吃n个食物的方法(吃的序列) [题解] 设f[i]表示长度为i的吃的序列且符合要求的 ...
- [Codeforces Round #340 (Div. 2)]
[Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...
- Codeforces 451E Devu and Flowers(容斥原理)
题目链接:Codeforces 451E Devu and Flowers 题目大意:有n个花坛.要选s支花,每一个花坛有f[i]支花.同一个花坛的花颜色同样,不同花坛的花颜色不同,问说能够有多少种组 ...
随机推荐
- spice up your desktop
https://wiki.gnome.org/Projects/GnomeShell/CheatSheet windows10用了一段时间,回来看着gnome3-shell是那么的恶心,翻来翻去重新整 ...
- c++判断一个字符串是否是数字
bool isNum(const string& str) { bool bRet = false; bool point = false; ) { return bRet; } ]) &am ...
- 报错 BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext 的解决方法
这个普遍是因为tomcat 的 jar包问题,重新导入一下tomcat的jar包就OK了.
- 【dp】 poj 1157
不错的dp入门题 画出dp矩阵 每个dp[i][j]是由“其上”的状态或是“其左上”的状态转化而来,那我们选对角线和上边进行三角dp推导 #include<stdio.h> #incl ...
- IO包中的其他类
查看各对象API文档 打印流 PrintWriter PrintStream 序列流:对多个流进行排列合并 SequenceInputStream public static void main(St ...
- cURL: Learning..
CURL usage.. -v, -m, -H, -I, -s, --connect-timeout, -x, -X GET|POST, -d, -T, -o. --retry, -u curl [o ...
- 项目管理实践教程一、工欲善其事,必先利其器【Basic Tools】
今天,我们首先安装一些必须的软件,主要有下面的4个,其中软件1和2使用在服务器机上,软件3和4安装在客户端机上.另外,我们还有用到MSBuild.RoboCopy.WebDeployment等等,在下 ...
- 双重检查锁定与延迟初始化(转自infoq)
很好的文章,转自http://www.infoq.com/cn/articles/double-checked-locking-with-delay-initialization 在java程序中,有 ...
- PAT (Advanced Level) 1112. Stucked Keyboard (20)
找出一定没问题的字符(即一连串的额字符x个数能被k整除的),剩下的字符都是可能有问题的. #include<cstdio> #include<cstring> #include ...
- CentOS服务端口开放
#例如开放81端口iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPTiptables -I OUTPUT -o eth0 -p tcp --sp ...