GYM 101617 F
说到这题还要提到周日下午训练赛,都进去了hmc说他这场单切过准备换一场。
很不幸的是我当时已经开了这个几何题,
开场就开几何是什么鬼啊!!!
给你n个圆,找一点在所有园内并且离原点最远。(保证有解)
我们肯定要援圆交啦!要素过多
其实我们可以大胆的猜测这个答案就在圆的交点上,
但是我们考虑到某种特殊情况,比方说只有一个圆,所以求一下原点与圆心的连线与圆的交点
再考虑到可能圆心就在原点上,特判一下,就ok了
//
// Created by gtx1080 on 2019-04-23.
//
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
const db eps=1e-;
const db pi=acos(-);
int sign(db k){
if (k>eps) return ; else if (k<-eps) return -; return ;
}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{
db x,y;
point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
point operator * (db k1) const{return (point){x*k1,y*k1};}
int operator == (const point &k1) const{return cmp(x,k1.x)==&&cmp(y,k1.y)==;}
db abs(){return sqrt(x*x+y*y);}
db abs2(){return x*x+y*y;}
db dis(point k1){return ((*this)-k1).abs();}
point turn90(){return (point){-y,x};}
point unit(){db w=abs(); return (point){x/w,y/w};}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
db dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}
point proj(point k1,point k2,point q){ // q 到直线 k1,k2 的投影
point k=k2-k1; return k1+k*(dot(q-k1,k)/k.abs2());
}
struct circle{
point o; db r;
int inside(point k){return cmp(r,o.dis(k))>=;}
};
int checkposCC(circle k1,circle k2){// 返回两个圆的公切线数量
if (cmp(k1.r,k2.r)==-) swap(k1,k2);
db dis=k1.o.dis(k2.o); int w1=cmp(dis,k1.r+k2.r),w2=cmp(dis,k1.r-k2.r);
if (w1>) return ; else if (w1==) return ; else if (w2>) return ;
else if (w2==) return ; else return ;
}
vector<point> getCC(circle k1,circle k2){// 沿圆 k1 逆时针给出 , 相切给出两个
int pd=checkposCC(k1,k2); if (pd==||pd==) return {};
db a=(k2.o-k1.o).abs2(),cosA=(k1.r*k1.r+a-k2.r*k2.r)/(*k1.r*sqrt(max(a,(db)0.0)));
db b=k1.r*cosA,c=sqrt(max((db)0.0,k1.r*k1.r-b*b));
point k=(k2.o-k1.o).unit(),m=k1.o+k*b,del=k.turn90()*c;
return {m-del,m+del};
}
vector<point> getCL(circle k1,point k2,point k3){ // 沿着 k2->k3 方向给出 , 相切给出两个
point k=proj(k2,k3,k1.o); db d=k1.r*k1.r-(k-k1.o).abs2();
if (sign(d)==-) return {};
point del=(k3-k2).unit()*sqrt(max((db)0.0,d)); return {k-del,k+del};
}
vector<point> mb,tmp;
void slove(circle a,circle b){
if(checkposCC(a,b)){
tmp = getCC(a,b);
mb.push_back(tmp[]);
mb.push_back(tmp[]);
}
}
void check(circle a){
if(a.o==(point){,})
return;
tmp = getCL(a,{,},a.o);
mb.emplace_back(tmp[]);
mb.emplace_back(tmp[]);
}
int n;circle c[];
db solve(point x){
for(int i=;i<=n;i++){
if(!c[i].inside(x))
return ;
}
return x.abs();
}
int main(){
scanf("%d",&n);
db nxt=;
for(int i=;i<=n;i++){
scanf("%lf%lf%lf",&c[i].o.x,&c[i].o.y,&c[i].r);
if(c[i].o==(point){,})nxt=min(nxt,c[i].r);
}
for(int i=;i<=n;i++){
check(c[i]);
for(int j=i+;j<=n;j++){
slove(c[i],c[j]);
}
}
db ans = ;
for(auto tmp:mb){
// printf("%.11f %.11f\n",tmp.x,tmp.y);
ans = max(ans,solve(tmp));
}
if(cmp(ans,)==&&nxt!=)
printf("%.3f\n",nxt);
else
printf("%.3f\n",ans);
}
GYM 101617 F的更多相关文章
- Gym 100637F F. The Pool for Lucky Ones
F. The Pool for Lucky Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- codeforces Gym 100187F F - Doomsday 区间覆盖贪心
F. Doomsday Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/F ...
- Codeforces gym 100685 F. Flood bfs
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Desc ...
- Gym 100637F F. The Pool for Lucky Ones 暴力
F. The Pool for Lucky Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- Codeforces Gym 100513F F. Ilya Muromets 线段树
F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/probl ...
- Codeforces Gym 100513F F. Ilya Muromets 水题
F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/probl ...
- Gym - 100283F F. Bakkar In The Army —— 二分
题目链接:http://codeforces.com/gym/100283/problem/F F. Bakkar In The Army time limit per test 2 seconds ...
- 2018-2019 XIX Open Cup, Grand Prix of Korea (Division 2) GYM 102058 F SG函数
http://codeforces.com/gym/102058/problem/F 题意:平面上n个点 两个人轮流在任意两个点之间连一条线但是不能和已有的线相交,先围成一个凸多边形的获胜,先手赢还 ...
- Gym 100952 F. Contestants Ranking
http://codeforces.com/gym/100952/problem/F F. Contestants Ranking time limit per test 1 second memor ...
随机推荐
- 2018-2019-2 20165221『网络对抗技术』Exp4:恶意代码分析
2018-2019-2 20165221『网络对抗技术』Exp4:恶意代码分析 实验要求: 是监控你自己系统的运行状态,看有没有可疑的程序在运行. 是分析一个恶意软件,就分析Exp2或Exp3中生成后 ...
- Sping 里面的适配器模式的实现
适配器模式----------设计模式最近在看SpringMVC源码,从中看到了比较优秀的设计模式所以来分享下. 1.适配器模式(Adapter):将一个类的接口转换成客户希望的另外一个接口,Adap ...
- git rejected - non-fast-forward
di第一次提交时可能提示此错误,应该是.gitignore冲突,建议码云创建时不要初始化,如果已经出现了.可以从git repostitory里合并. 参考:https://blog.csdn.ne ...
- python 字符串转化为json、post请求
在json模块有2个方法, loads():将json数据转化成dict数据 dumps():将dict数据转化成json数据 load():读取json文件数据,转成dict数据 dump():将d ...
- Go语言--数组、切片、
3.1 数组--固定大小的连续空间 3.1.1 声明数组 写法 var 数组变量名 [元素数量]T 说明: 变量名就是使用时的变量 元素的数量可以是表达式,最后必须为整型数值 T 可是是任意基本类型, ...
- Tensorflow笔记二
MNIST手写体识别 (Mixed National Institute of Standards and Technology database)的28*28字符识别共0-9类. 在ipython命 ...
- python3中的type与object
在python中,一切皆对象,应该怎么理解呢?? 先来看几个例子: [root@localhost ~]# python3 Python 3.6.3rc1 (default, Feb 26 2018, ...
- JAVA第三次实训作业
---恢复内容开始--- 1. 编写“学生”类及其测试类. “学生”类: 类名:Student 属性:姓名.性别.年龄.学号.5门课程的成绩 方法1:在控制台输出各个属性的值. 方法2:计算平均成绩 ...
- 前端开发【第1篇:HTML】
HTML初识 1.什么是HTML HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记).相当于定义统一的一套规则,大家都 ...
- SQLAlchemy使用介绍
SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers ...