ACdream1414 Geometry Problem
Problem Description
At the last lesson the students were studying circles. They learned how to draw circles with compasses. Peter has completed most of his homework and now he needs to solve the following problem. He is given two segments. He needs to draw a circle which
intersects interior of each segment exactly once.
The circle must intersect the interior of each segment, just touching or passing through the end of the segment is not satisfactory.
Help Peter to complete his homework.
Input
The first line of the test case contains four integer numbers x11, y11,
x12, y12— the coordinates of the ends
of the first segment. The second line contains x21. y21,
x22, y22 and describes the second
segment in the same way.
Input is followed by two lines each of which contains four zeroes these lines must not be processed.
All coordinates do not exceed 102 by absolute value.
Output
their absolute values. The jury makes all comparisons of real numbers with the precision of 10-4.
Sample Input
0 0 0 4
1 0 1 4
0 0 0 0
0 0 0 0
Sample Output
0.5 0 2
Hint

Source
Andrew Stankevich Contest 22
这题是几何题,先把线段的端点都连起来,共4条线段,然后选择最短的那条线段,取这条线段的中点,中点即为圆心,半线段长为l1,算出这个点到另外两点连线的较小长度l2,然后圆的半径就是(l1+l2)/2;
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
#define inf 88888888
struct node{
double dis,x,y,xx,yy;
}a[10];
struct student{
double x,y;
}b[10];
double dist(double x,double y ,double xx,double yy){
return sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));
}
bool cmp(node a,node b){
double temp;
if(a.dis>b.dis){
temp=a.x;a.x=b.x;b.x=temp;
temp=a.xx;a.xx=b.xx;b.xx=temp;
temp=a.yy;a.yy=b.yy;b.yy=temp;
temp=a.y;a.y=b.y;b.y=temp;
return a.dis<b.dis;
}
return a.dis<b.dis;
}
int main()
{
int n,m,i,j;
double x,y,dis1,dis2,x2,y2,x3,y3,x4,y4,x5,y5,disend,len;
while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x2,&y2,&x3,&y3,&x4,&y4,&x5,&y5)!=EOF)
{
if(x2==0 && y2==0 && x3==0 && y3==0 && x4==0 && y4==0 && x5==0 && y5==0)break;
a[1].dis=dist(x3,y3,x5,y5);a[1].x=x3;a[1].y=y3;a[1].xx=x5;a[1].yy=y5;
a[2].dis=dist(x2,y2,x4,y4);a[2].x=x2;a[2].y=y2;a[2].xx=x4;a[2].yy=y4;
a[3].dis=dist(x3,y3,x4,y4);a[3].x=x3;a[3].y=y3;a[3].xx=x4;a[3].yy=y4;
a[4].dis=dist(x2,y2,x5,y5);a[4].x=x2;a[4].y=y2;a[4].xx=x5;a[4].yy=y5;
sort(a+1,a+5,cmp);
x=(a[1].x+a[1].xx)/2;
y=(a[1].y+a[1].yy)/2;
b[2].x=x2;b[2].y=y2;
b[3].x=x3;b[3].y=y3;
b[4].x=x4;b[4].y=y4;
b[5].x=x5;b[5].y=y5;
len=inf;
for(i=2;i<=5;i++){
if((b[i].x==a[1].x && b[i].y==a[1].y) || (b[i].x==a[1].xx && b[i].y==a[1].yy))continue;
if(dist(b[i].x,b[i].y,x,y)<len)
len=dist(b[i].x,b[i].y,x,y);
}
disend=(len+a[1].dis/2.0)/2;
printf("%.4f %.4f %.4f\n",x,y,disend);
}
return 0;
}
ACdream1414 Geometry Problem的更多相关文章
- HDU1086You can Solve a Geometry Problem too(判断线段相交)
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- codeforces 361 E - Mike and Geometry Problem
原题: Description Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him ...
- hdu 1086 You can Solve a Geometry Problem too
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- CodeForces 689E Mike and Geometry Problem (离散化+组合数)
Mike and Geometry Problem 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/I Description M ...
- Codeforces Gym 100338B Geometry Problem 计算几何
Problem B. Geometry ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudg ...
- you can Solve a Geometry Problem too(hdoj1086)
Problem Description Many geometry(几何)problems were designed in the ACM/ICPC. And now, I also prepare ...
- (hdu step 7.1.2)You can Solve a Geometry Problem too(乞讨n条线段,相交两者之间的段数)
称号: You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/ ...
- HDU 1086:You can Solve a Geometry Problem too
pid=1086">You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Mem ...
- You can Solve a Geometry Problem too(判断两线段是否相交)
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
随机推荐
- Haproxy-1.8.20 根据路径(URI)转发到后端不同集群
HAProxy根据不同的URI 转发到后端的服务器组 1 ) 实验内容说明: 1.1 ) 根据不同的URI 转发到后端的服务器组. /a /b 和其他 默认使用其他. 1.2 ) 使用IP介绍: ha ...
- NAS基础知识
一.什么是NAS 1.NAS的定义 NAS(Network Attached Storage:网络附属存储)按字面简单说就是连接在网络上,具备资料存储功能的装置,因此也称为"网络存储器&qu ...
- Mysql数据类型以及特性,,,防止SQL注入
MyISAM.InnoDB.HEAP.BOB,ARCHIVE,CSV等 MyISAM:成熟.稳定.易于管理,快速读取.一些功能不支持(事务等),表级锁. InnoDB:支持事务.外键等特性.数据行锁定 ...
- Memcached、Redis、Mongodb比较
Memcached(内存Cache) Memcached 是一个高性能的分布式内存对象缓存系统.通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像.视频.文件以及数据库 ...
- Netty学习:ChannelHandler执行顺序详解,附源码分析
近日学习Netty,在看书和实践的时候对于书上只言片语的那些话不是十分懂,导致尝试写例子的时候遭遇各种不顺,比如decoder和encoder还有HttpObjectAggregator的添加顺序,研 ...
- 通过logmnr找到被修改前的存储过程
1.找到存储过程被修改时的归档日志 SELECT NAME FROM V$ARCHIVED_LOG WHERE FIRST_TIME BETWEEN TO_DATE('20191118080000', ...
- 两节锂电池充电芯片,和保护IC的接法
1.两节锂电池的充电电路:可以分为三种方式. 第一种,USB口的5V输入,使用一颗SOT23-6的升压IC,直接升压到8.4V.电流在1A以下.优点是成本最低,缺点是,没有锂电池充电控制逻辑,和锂电池 ...
- MYSQL面试题-索引
MYSQL面试题-索引 引自B站up编程不良人:https://www.bilibili.com/video/BV19y4y127h4 一.什么是索引? 官方定义:索引是一种帮助mysql提高查询效率 ...
- 【CentOS7】Apache发布静态网页-超简单
目前能够提供Web网络服务的程序有 IIS. Nginx和 Apache等.其中,IIS (Internet Information Services,互联网信息服务)是 Windows系统中默认的 ...
- 架构风格 vs. 架构模式 vs. 设计模式(译)
4.架构风格 vs. 架构模式 vs. 设计模式(译) - 简书 https://www.jianshu.com/p/d8dce27f279f