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 ...
随机推荐
- 20181023-9 Alpha阶段第2周/共2周 Scrum立会报告+燃尽图 06
作业要求参见: https://edu.cnblogs.com/campus/nenu/2018fall/homework/2289 Scrum master:赵佳璐 一.小组介绍 组长:王一可 组员 ...
- 20181009-3 Scrum立会报告+燃尽图02
此作业要求:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2190] 一.小组介绍 组长:王一可 组员:范靖旋,王硕,赵佳璐,范洪达,祁 ...
- HDU 5195 DZY Loves Topological Sorting 拓扑排序
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5195 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- 【BioCode】将多个蛋白质序列分成单个的txt文档
代码说明: fasta格式的蛋白质序列,一个txt里面有很多蛋白质序列,计算ss.pssm或disorder score时候都需要单条计算,需要分开. 分割前: 分割后: show you the c ...
- Django之logging日志
简介 Django使用python自带的logging 作为日志打印工具.简单介绍下logging. logging 是线程安全的,其主要由4部分组成: Logger 用户使用的直接接口,将日志传递给 ...
- Java容器深入浅出之String、StringBuffer、StringBuilder
对字符串的花式处理一直是现代应用系统的主要操作之一,也是对Java基础知识考察的重要方面.事实上,Java字符串类的底层是通过数组来实现的.具体来说,String类是固定长度的数组,StringBuf ...
- CCSDS标准的LDPC编译码仿真
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- bzoj4569-萌萌哒
题目 有一个长度为\(n\)的十进制数,用\(s\)表示.有\(m\)个限制条件,每个条件形如:\((l_1,r_1,l_2,r_2)\),表示\(s[l_1:r_1]=s[l_2:r_2]\). 现 ...
- C++解析(6):函数参数的扩展
0.目录 1.函数参数的默认值 2.函数默认参数的规则 3.函数占位参数 4.小结 1.函数参数的默认值 C++可以在函数声明时为参数提供一个默认值 当函数调用时没有提供参数的值,则使用默认值 参数的 ...
- debug - vue中通过ajax获取数据时,如何避免绑定的数据中出现property of undefined错误
因为获取服务器是异步的,所以 vue 先绑定数据. 如果 ??? 是通过 ajax 异步获取的,在获取之前,???是未定义的.此时在外面的标签上添加一个 v-if="???" 可以 ...