ACdream 1414(计算几何)
来源:互联网 发布:高压柜模型实时数据 编辑:程序博客网 时间:2024/06/14 09:00
题目链接:http://115.28.76.232/problem?pid=1414
Problem Description
Peter is studying in the third grade of elementary school. His teacher of geometry often gives him difficult home tasks.
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.
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 input file contains several test cases. Each test case consists of two lines.
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.
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
For each test case output three real numbers — the coordinates of the center and the radius of the circle. All numbers in the output file must not exceed 1010 by their absolute values. The jury makes all comparisons of real numbers with the precision of 10-4.
Sample Input
0 0 0 41 0 1 40 0 0 00 0 0 0
Sample Output
0.5 0 2
Hint
Source
Andrew Stankevich Contest 22
题意: 求一个圆 ,使其与两条线段都有且只有一个交点;
分析:找找出两个线段的两个端点的最小距离 ,这两个端点的中点为圆心,这个最小距离加上一个很小的值即为半径
代码如下:
#include <iostream>#include <cstdio>#include <cmath>using namespace std;struct point{ double x,y;};double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){ point a,b,c,d; while(cin>>a.x>>a.y>>b.x>>b.y){ cin>>c.x>>c.y>>d.x>>d.y; if(!a.x&&!a.y&&!b.y&&!b.x&&!c.x&&!c.y&&!d.x&&!d.y) break; point cir; double r; double aa[4]; aa[0]=dis(a,c),aa[1]=dis(a,d),aa[2]=dis(b,c),aa[3]=dis(b,d); point tmp1,tmp2; double dd=min(min(aa[0],aa[1]),min(aa[2],aa[3])); if(dd==aa[0]){ cir.x=(a.x+c.x)/2; cir.y=(a.y+c.y)/2; } else if(dd==aa[1]){ cir.x=(a.x+d.x)/2; cir.y=(a.y+d.y)/2; } else if(dd==aa[2]){ cir.x=(b.x+c.x)/2; cir.y=(b.y+c.y)/2; } else if(dd==aa[3]){ cir.x=(b.x+d.x)/2; cir.y=(b.y+d.y)/2; } r=dd/2.0+0.001; printf("%lf %lf %lf\n",cir.x,cir.y,r); } return 0;}
0 0
- ACdream 1414(计算几何)
- ACdream 1414(计算几何)
- 几何水题 acdream 1414 Geometry Problem
- ACdream 1107 瑶瑶迷上新游戏 (计算几何+确认抛物线)
- ACdream 1106 游泳水平有限的瑶瑶 (计算几何)(点到直线的最短距离)
- 计算几何几何函数库
- 计算几何-几何库
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 数字电路设计之Wallace树形乘法器
- 应用状态VS资源状态
- 数论基础之辗转相除法求最大公约数
- HTTP的可见性
- 【无限互联】框架学习——MCSwipeTableViewCell
- ACdream 1414(计算几何)
- INS-20802
- 专注于现在
- ROA的两个特性
- 统计大写字母个数——来自华为OJ平台测试基础篇
- Command Execution Source--medium
- cocos2d-x 3.2 2048——第六篇(最终章)
- 什么是资源
- PHP外观模式