ACM-ICPC2018 沈阳赛区网络预赛-E-The cake is a lie
You promised your girlfriend a rounded cake with at least SS strawberries.
But something goes wrong, you don't have the final cake but an infinite plane with NN strawberries on it. And you need to draw a circle which contains strawberries completely to make the cake by yourself.
To simplify the problem, the strawberries are represented as circles in 22D plane. Every strawberry has its center (X_i, Y_i)(Xi,Yi) and the same radius RR.
The cost of your cake is the radius of the circle you draw. So you want to know the minimal cost of the cake, or if you can't give your girlfriend such a cake.
Input
The input file contains several test cases.
The first line of the file is an integer TT, giving the number of test cases. (T\leq20)(T≤20)
For each test case, there are two integers NN and SS in the first line, denoting the number of total strawberries and the number of strawberries on cake as you promised. (1\leq N, S \leq 300)(1≤N,S≤300)
In the following NN lines, each line contains two integers X_i, Y_iXi,Yi, denoting the coordinates of the strawberry center. (0\leq X_i, Y_i\leq 10000)(0≤Xi,Yi≤10000)
The next line contains one integer RR, denoting the radius of all strawberries. (1\leq R \leq 10000)(1≤R≤10000)
It's guaranteed that sum of NN is smaller than 10001000.
Output
Output the minimal cost correct to four decimal places if you can make a rounded cake with at least SSstrawberries, or "The cake is a lie."
if not.
样例输入
2
5 3
0 0
0 2
2 0
0 0
1 1
1
1 2
0 0
1
样例输出
1.7071
The cake is a lie.
题意是给你一堆半径相等的圆,让你求一个最小的圆能覆盖其中至少m个圆 首先把他给的圆看成点,然后找个最小的圆覆盖覆盖其中至少m个点,然后答案就是现在找的这个圆的半径加那一堆圆的半径
二分一个答案,以每个点的圆心为圆心,二分的答案为半径画圆,能被覆盖的点必然画出的圆相交。
对这些圆极角排序,然后扫描,圆第一次被扫描到就+,第二次被扫描到就-,这个过程中的最大值就是能覆盖的点
意会一下……
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
const int N=;
int n,m,T;
double R;
struct Point{
double x,y;}p[N];
struct orz{
double du;
int flag;}a[*N];
bool cmp(orz a,orz b)
{
if (a.du!=b.du) return a.du<b.du;
return a.flag>b.flag;
}
double dist(Point a,Point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double f(Point a,Point b)
{
return atan2(b.y-a.y,b.x-a.x);
}
bool check(double x)
{
int ans=;
for (int i=;i<=n;i++)
{
int cnt=;
for (int j=;j<=n;j++)
{
if (j==i) continue;
if (dist(p[i],p[j])<=*x)
{
double mid=f(p[j],p[i]);
double xx=acos(dist(p[i],p[j])/2.0/x);
a[cnt].du=mid-xx; a[cnt++].flag=;
a[cnt].du=mid+xx; a[cnt++].flag=;
}
} sort(a,a+cnt,cmp);
int tmp=;
for (int j=;j<cnt;j++)
{
if (a[j].flag) tmp++;
else tmp--;
ans=max(ans,tmp);
}
}
return ans>=m;
}
int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%d%d",&n,&m);
for (int i=;i<=n;i++) scanf("%lf%lf",&p[i].x,&p[i].y);
scanf("%lf",&R); double l=,r=1e5,ans=-;
for (int i=;i<=;i++)
{
double mid=(l+r)/2.0;
if (check(mid)) r=mid,ans=mid;
else l=mid;
}
if (ans<) printf("The cake is a lie.\n");
else printf("%.4f\n",ans+R);
}
return ;
}
ACM-ICPC2018 沈阳赛区网络预赛-E-The cake is a lie的更多相关文章
- ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)
https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...
- ACM-ICPC 2018 沈阳赛区网络预赛-K:Supreme Number
Supreme Number A prime number (or a prime) is a natural number greater than 11 that cannot be formed ...
- ACM-ICPC 2018 沈阳赛区网络预赛-D:Made In Heaven(K短路+A*模板)
Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. ...
- 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven
131072K One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...
- ACM-ICPC 2018 沈阳赛区网络预赛 J树分块
J. Ka Chang Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero p ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K. Supreme Number
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...
- ACM-ICPC 2018 沈阳赛区网络预赛 B Call of Accepted(表达式求值)
https://nanti.jisuanke.com/t/31443 题意 给出一个表达式,求最小值和最大值. 表达式中的运算符只有'+'.'-'.'*'.'d',xdy 表示一个 y 面的骰子 ro ...
- ACM-ICPC 2018 沈阳赛区网络预赛 G Spare Tire(容斥)
https://nanti.jisuanke.com/t/31448 题意 已知a序列,给你一个n和m求小于n与m互质的数作为a序列的下标的和 分析 打表发现ai=i*(i+1). 易得前n项和为 S ...
随机推荐
- Alpha发布——美工+文案
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2283 一.功能介绍 本团队(可以低头,但没必要)开发的是一款基于腾讯微信 ...
- 软工第十二周个人PSP
11.30--12.6本周例行报告 1.PSP(personal software process )个人软件过程. C(类别) C(内容) ST(开始时间) ET(结束时间) INT(间隔时间) Δ ...
- Python:文件操作总结1——文件基本操作
一.文件的操作流程 1.打开文件,得到文件句柄并赋值给一个变量 2.通过句柄对文件进行操作 3.关闭文件 二.文件的打开与关闭 A.文件的打开——open函数 语法:open(file[,mode[, ...
- CS小分队第一阶段冲刺站立会议(5月11日)
昨日成果:完成了倒计时器的制作,为其添加了声音:并对扫雷游戏的失败添加了动态效果: 遇到的困难:把图片放入picturebox中无法改变图片的大小,音乐格式只能使用.wav,该格式音乐比较大,增加了整 ...
- 第八次作业(课堂实战)- 项目UML设计
本次作业博客 团队信息 队名:起床一起肝活队 原组长: 白晨曦(101) 原组员: 李麒 (123) 陈德斌(104) 何裕捷(214) 黄培鑫(217) 王焕仁(233) 林志华(128) 乐忠豪( ...
- EF动态排序
转载的代码,改天再研究 public PageData<T> FindAll(int PageIndex, int PageSize, Expression<Func<T, b ...
- centos系统下禁用笔记本触控板
最近把零几年的老爷笔记本拿出来用,使用windows系统实在太卡了,于是折腾安装上Centos系统了,但是在使用的过程中发现鼠标经常失效.使用了多种方法(比如:http://blog.csdn.net ...
- 单源最短路径spfa模板(pascal)洛谷P3371
题目描述 如题,给出一个有向图,请输出从某一点出发到所有点的最短路径长度. 输入输出格式 输入格式: 第一行包含三个整数N.M.S,分别表示点的个数.有向边的个数.出发点的编号. 接下来M行每行包含三 ...
- [二十一]SpringBoot 之 导入xml配置
SpringBoot理念就是零配置编程,但是如果绝对需要使用XML的配置,我们建议您仍旧从一个@Configuration类开始,你可以使用@ImportResouce注解加载XML配置文件,我拿一个 ...
- 深入理解JVM一JVM内存模型
前言 JVM一直是java知识里面进阶阶段的重要部分,如果希望在java领域研究的更深入,则JVM则是如论如何也避开不了的话题,本系列试图通过简洁易读的方式,讲解JVM必要的知识点. 一.运行流程 我 ...