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 ...
随机推荐
- Shiro的认证与授权
shiro实战教程 一.权限管理 1.1什么是权限管理 基本上涉及到用户参与的系统都需要进行权限管理,权限管理属于系统安全的范畴,权限管理实现对用户访问系统的控制,按照安全规则或者安全策略控制用户可以 ...
- python_元组(tuple)
#tuple(),元组不可以修改,不能对其进行增加或删除操作,元组是有序的 #1.定义 tu_1 = () #定义一个空元组 tu_2 = (1,2,'alex',[3,4],(5,6,7),True ...
- FAT32、NTFS、exFAT有什么区别?
文件系统 我们经常会对电脑硬盘.U盘.移动硬盘进行格式化,而在格式化硬盘的时候会弹出文件系统的选项,分别有FAT32.NTFS.exFAT三种格式,那么FAT32.NTFS.exFAT有什么区别? 在 ...
- Hadoop源码:namenode格式化和启动过程实现
body { margin: 0 auto; font: 13px / 1 Helvetica, Arial, sans-serif; color: rgba(68, 68, 68, 1); padd ...
- wmic 查看主板信息
查看主板信息的一个命令:wmic baseboard get 当然在命令提示符里查看,真的很费劲,所以我们将命令格式化一下:wmic baseboard get /format:HFORM >c ...
- win32 sdk 环境下创建状态栏
今天在学习状态栏,出了好多的问题,这里记录下. 要创建状态栏用:CreateStatusWindow CreateStatusWindow函数创建一个状态窗口,通常用于显示应用程序的状态.窗口通常显示 ...
- Mybatis解决字段与属性不匹配的问题、链表查询、嵌套查询、#{}和${}的区别
1.使用接口结合xml映射文件 创建一个接口,该接口要和映射文件匹配(接口中方法名要和映射文件中的id相同) 映射文件中命名空间要和接口全类名相同 测试: 创建一个与src同级的源文件夹resourc ...
- missing required library sqlite.dll最终解决办法
missing required library sqlite.dll最终解决办法 昨天电脑还是好的,今天早晨打开navicat连接Mysql无缘无故报错"missing required ...
- elasticsearch从开始到永久
0.学习目标 独立安装Elasticsearch 会使用Rest的API操作索引 会使用Rest的API查询数据 会使用Rest的API聚合数据 掌握Spring Data Elasticsearch ...
- 一站式入口服务|爱奇艺微服务平台 API 网关实战 原创 弹性计算团队 爱奇艺技术产品团队
一站式入口服务|爱奇艺微服务平台 API 网关实战 原创 弹性计算团队 爱奇艺技术产品团队