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]支花.同一个花坛的花颜色同样,不同花坛的花颜色不同,问说能够有多少种组 ...
随机推荐
- 用For Each语句对Session.Contents树组进行遍历
<%@ LANGUAGE=VBScript codepage ="936" %> <% Option Explicit %> 您的sessionID号是:& ...
- Setup a private http/nginx based GIT server
原文:http://aaba.me/blog/2014/03/setup-a-private-http-nginx-based-git-server.html https://doomzhou.git ...
- 诡异的php 输出缓冲
我的本地环境 windows + apche + php5.2 今天,碰到一个诡异的问题,以前认为 php 脚本中调用 heade()函数之前不能有任何的如 echo,print ,print_r, ...
- eclipse提升注解提示速度
preference--输入content--java--editor--content Assist--aoto delay 选项 改为100或者更低 提示速度 --ao ...
- POJ 2368 巴什博奕
题目大意:给出n个按钮,每次最多可以按L个,按下最后一个按钮的人获胜.求使后手必定获胜的L的最小值(L>=2). 题目思路: 巴什博弈:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少 ...
- Tinyxml封装类COperatorXml
OperatorXml.h头文件 #ifndef _OPERATOR_XML_H_ #define _OPERATOR_XML_H_ #include <string> class TiX ...
- linux视频学习4(crontab和进程)
1 . crontab定时任务: 任务调度: 系统在某个时间执行的特定的命令. 分类: 1.系统工作.2.个别的用户工作. 设置任务调度文件: /etc/crontab 1.crontab -e : ...
- ReactiveCocoa & FRP & MVVM
Functional Reactive Programming(以下简称FRP)是一种响应变化的编程范式.先来看一小段代码 a = 2 b = 2 c = a + b // c is 4 b = 3 ...
- 求交集,差集,并集,善用java的set
当有题目有求这些结果时,使用集合数据结构还是很快的.需要考虑的是,注意map和set的区别. public static void main(String[] args) { Set<Integ ...
- 最短路径算法专题3----Bellman-Ford
这个算法也是求单源最短路径用的,但是这个算法可以解决Dijkstra不能解决的负权边问题. 算法要点: 1.用dis存放源点到任意一点的距离. 2.用三个数组存放输入的点到点以及点到点的距离,x[i] ...