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 ...
随机推荐
- Java 学习笔记 ------第一章 Java平台概论
本章学习目标: Java版本迁移简介 认识Java SE.Java EE.Java ME 认识JDK规范与操作 了解JVM.JRE与JDK 下载与安装JDK 一.Java版本迁移简介 书上已经表达得非 ...
- CS小分队第一阶段冲刺站立会议(5月13日)
昨日成果:昨日由于课程满课,未进行项目的制作 遇到困难:/ 今天计划:为2048和扫雷添加游戏音效,和组员一起合作对扫雷进行外观美化,学习程序生成时渐隐等特效
- tensorflow训练线性回归模型
tensorflow安装 tensorflow安装过程不是很顺利,在这里记录一下 环境:Ubuntu 安装 sudo pip install tensorflow 如果出现错误 Could not f ...
- 博弈--ZOJ 3084 S-Nim(SG)
题意: 首先输入K 表示一个集合的大小 之后输入集合 表示对于这对石子只能去这个集合中的元素的个数 之后输入 一个m 表示接下来对于这个集合要进行m次询问 之后m行 每行输入一个n 表示有n个堆 ...
- CodeForces 154A Hometask dp
题目链接: http://codeforces.com/problemset/problem/154/A 题意: 给你一个字符串,和若干模板串(长度为2),至少删除多少个字母,使得字符串的字串里面没有 ...
- 软工网络15团队作业4-DAY8
每日例会 昨天的工作. 张陈东芳:可导入部分类信息,继续尝试将所有信息导入: 吴敏烽:商品类的规范化编写: 周汉麟:界面的排版继续优化: 林振斌:按照浏览历史,次数等,继续优化商品类排序: 李智:研究 ...
- 1st 英文文章词频统计
英文文章词频统计: 功能:统计一篇英文文章的单词总数及出现频数并输出,之后排序,输出频数前十的单词及其频数. 实现方法:使用C语言,用fopen函数读入txt文件,fscanf函数逐个读入单词,结构体 ...
- elementUI使用本地变量进行验证,监测不到本地变量的变化 的问题
对于饿了么组件自定义验证规则,组件库文档已经非常详细了:http://element-cn.eleme.io/#/zh-CN/component/form 我这里将验证中固定的值提取出来使用变量进行保 ...
- PHP《将画布(canvas)图像保存成本地图片的方法》
用PHP将网页上的Canvas图像保存到服务器上的方法 2014年6月27日 歪脖骇客 发表回复 8 在几年前HTML5还没有流行的时候,我们的项目经理曾经向我提出这样一个需求:让项目评审专家们在评审 ...
- UVA12585_Poker End Games
题目是这样的,每个人手中有a和b的钱数,c为a和b中间最小的一个. 每个回合,两个人胜利的概率都是0.5,胜利者从失败者手中获得c的钱数. 如果有一个人手中没钱的话,那么他就failer,游戏结束. ...