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 ...
随机推荐
- gitlab 权限说明
五.权限说明 Guest(匿名用户) - 创建项目.写留言薄 Reporter(报告人)- 创建项目.写留言薄.拉项目.下载项目.创建代码片 段 Developer(开发者)- 创建项目.写留言薄.拉 ...
- spring MVC 项目 WEB-INF下的jsp不能加载css文件
一.项目目录 二.解决方法(已解决) 1. jsp文件加入 <link href="<c:url value="/css/main.css" />&qu ...
- 公设基础Generic
1# 与泛型相关的一些术语 1.类型参数(type parameter) : EX: List<E> 这里的E就属于List接口的单个类型参数E 2.参数化的类型(parameterize ...
- css背景图片充满DIV
最近接手前端页面,让给调样式.哥纯粹一个代码程序猿,表示那些个样式应该让前端人员或者美工小妹妹来实现. 书归正传,碰到了问题,页面要在手机上展现,众所周知,手机在中国的牌子很多,很难做到统一. 页面上 ...
- VB 字符串转换为UTF-8
dim e as object Set e=CreateObject("MSScriptControl.ScriptControl") e.Language = "jav ...
- C#如何实现DataGridView单元格拖拽
参考: http://www.cnblogs.com/michaelxu/archive/2009/09/27/1574905.html
- Angular结构型指令,模块和样式
结构型指令 *是一个语法糖,<a *ngIf="user.login">退出</a>相当于 <ng-template [ngIf]="use ...
- arcgis js 鼠标点和绘制的点位有偏移
问题描述:鼠标点和绘制的点位有偏移 问题原因:地图DIV中包含了一个面板DIV,停靠在了地图页面的左边,隐藏掉就是正确了 解决方法:重写DIV样式,让左边DIV与地图DIV平级排列.
- 10_30_unittest
1.断言 1).self.assertEqual(2,res)#期望值qian.结果值hou2)TextTestRunner 源码 必要的参数3)测试结果 上下文管理器 with open(" ...
- 闲谈REST API
REST 表述性状态传递(英文:Representational State Transfer,简称REST). 资源: 资源由URI(统一资源定位符)的来指定. 通过资源的表现形式来操作资源 对资源 ...