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 ...
随机推荐
- GX/GZOI2019 day2 解题报告
GX/GZOI2019 day2 解题报告 题目链接 逼死强迫症 旅行者 旧词 t1 逼死强迫症 显然地,记 \(f(i)\) 为长度为 \(i\) 的木板的答案,可得: \(\\\) \[f(i)= ...
- rethinking imageNet pre-training
paper url: https://arxiv.org/abs/1811.08883  当在数据量足够和训练iterations足够的情况下,ImageNet pretrain不会对最后的性能有帮 ...
- Debug Dump file
dump file is a snapshot of the processs memeory. to debug it, we need use its corresponding executiv ...
- springboot动态多数据源
参考文章:https://www.cnblogs.com/hehehaha/p/6147096.html 前言 目标是springboot工程支持多个MySQL数据源,在代码层面上,同一个SQL(Ma ...
- java 生产者消费者简单实现demo
第一种方式 使用BlockingQueue 阻塞队列 public class Threads { public static void main(String[] args) { final Arr ...
- 关于mvc中传递匿名对象,view中无法解析
最近做项目用到MVC,发现用linq查询得到的数据是匿名类型对象,通过模型绑定.或者ViewBag.ViewData进行数据传递后,View解析报错:“object 未包含xx的定义”: 没找到好的解 ...
- 一场由like引发的事故
故事背景: 有一张用户级表,数据量在千万级别,而运营人员要查看这张表,其中有一项查询条件为根据“错误类型”(单值)查出所有包含这个类型的数据,而这个数据类型在数据库存放的方式类似于 “1,2,3,4, ...
- python输入一行字符,判断不同字符数量
输入一行字符,判断不同字符的数量, 分别用for循环和while循环完成 for循环 运用了字符串方法, isupper()判断是否为大写字母 islower()判断是否为小写字母 isdigit() ...
- 学习日志1 :java 三大框架 了解
1.spring--------利用它的IOC和AOP来处理控制业务(负责对数据库的操作) https://blog.csdn.net/yu616568/article/details/7073997 ...
- javaScript -- touch事件详解(touchstart、touchmove和touchend)
HTML5中新添加了很多事件,但是由于他们的兼容问题不是很理想,应用实战性不是太强,所以在这里基本省略,咱们只分享应用广泛兼容不错的事件,日后随着兼容情况提升以后再陆续添加分享.今天为大家介绍的事件主 ...