HDU 1374 The Circumference of the Circle 计算几何
来源:互联网 发布:淘宝打折软件怎么用 编辑:程序博客网 时间:2024/05/20 20:01
题目的链接如下:
http://acm.hdu.edu.cn/showproblem.php?pid=1374
The Circumference of the Circle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 920 Accepted Submission(s): 685
Problem Description
To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don’t?
You are given the cartesian coordinates of three non-collinear points in the plane.
Your job is to calculate the circumference of the unique circle that intersects all three points.
Input
The input file will contain one or more test cases. Each test case consists of one line containing six real numbers x1,y1, x2,y2,x3,y3, representing the coordinates of the three points. The diameter of the circle determined by the three points will never exceed a million. Input is terminated by end of file.
Output
For each test case, print one line containing one real number telling the circumference of the circle determined by the three points. The circumference is to be printed accurately rounded to two decimals. The value of pi is approximately 3.141592653589793.
Sample Input
0.0 -0.5 0.5 0.0 0.0 0.5
0.0 0.0 0.0 1.0 1.0 1.0
5.0 5.0 5.0 7.0 4.0 6.0
0.0 0.0 -1.0 7.0 7.0 7.0
50.0 50.0 50.0 70.0 40.0 60.0
0.0 0.0 10.0 0.0 20.0 1.0
0.0 -500000.0 500000.0 0.0 0.0 500000.0
Sample Output
3.14
4.44
6.28
31.42
62.83
632.24
3141592.65
完全的模板,求不共线的三点的外接圆。
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#define eps 1e-8#define PI 3.141592653589793struct Tpoint{ double x,y; Tpoint operator-(Tpoint&a){ Tpoint p1; p1.x=x-a.x; p1.y=y-a.y; return p1; }};double dist(Tpoint p1,Tpoint p2) // 返回两点之间欧氏距离{ return( sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ) );}Tpoint q;//圆心double r, l;void cocircle(Tpoint p1,Tpoint p2,Tpoint p3){ double x12=p2.x-p1.x; double y12=p2.y-p1.y; double x13=p3.x-p1.x; double y13=p3.y-p1.y; double z2=x12*(p1.x+p2.x)+y12*(p1.y+p2.y); double z3=x13*(p1.x+p3.x)+y13*(p1.y+p3.y); double d=2.0*(x12*(p3.y-p2.y)-y12*(p3.x-p2.x)); q.x=(y13*z2-y12*z3)/d; q.y=(x12*z3-x13*z2)/d; r=dist(p1,q); l = 2 * PI * r; return ;}using namespace std;int main() { Tpoint ans; Tpoint a[10]; while(~scanf("%lf%lf%lf%lf%lf%lf",&a[1].x,&a[1].y,&a[2].x,&a[2].y,&a[3].x,&a[3].y)){ cocircle(a[1], a[2], a[3]); printf("%.2f\n", l); } return 0;}
- HDU 1374 The Circumference of the Circle 计算几何
- 计算几何 The Circumference of the Circle
- The Circumference of the Circle(计算几何)
- hdu 1374 The Circumference of the Circle
- POJ 2242 The Circumference of the Circle (计算几何)
- UVa 438 The Circumference of the Circle (计算几何)
- UVA 438 - The Circumference of the Circle(计算几何)
- 438 - The Circumference of the Circle【几何】
- uva 438 - The Circumference of the Circle(几何)
- The Circumference of the Circle
- POJ2242_The Circumference of the Circle(几何/三角形外接圆周长/模板)
- pku2242The Circumference of the Circle
- HDOJ 1374 The Circumference of the Circle (求外接圆)
- zoj1090 The Circumference of the Circle
- ZOJ1090 The Circumference of the Circle
- POJ 2242 The Circumference of the Circle
- poj 2242 The Circumference of the Circle
- zoj 1090 The Circumference of the Circle
- Codeforce Gym 100819P : 2015-2016 ACM-ICPC Pacific Northwest Regional Contest - P 仔细看题啊!
- 0058 连续子数组的最大和
- 我的安卓开发学习系列零:为什么选择安卓
- [狗尾续貂第三篇]Redis Sentinel
- json数据转换实例
- HDU 1374 The Circumference of the Circle 计算几何
- Java 标识符
- MATLAB 临时代码-1
- 闲杂小记(五)
- 读取记事本里面的内容
- Sping学习笔记1
- 设计模式-适配器模式
- Android事件总线(一)EventBus3.0用法全解析
- 条件概率与条件概率举例