POJ2242_The Circumference of the Circle(几何/三角形外接圆周长/模板)
来源:互联网 发布:sql关联查询 编辑:程序博客网 时间:2024/05/20 19:49
The Circumference of the Circle
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7017 Accepted: 4353
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.
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 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.50.0 0.0 0.0 1.0 1.0 1.05.0 5.0 5.0 7.0 4.0 6.00.0 0.0 -1.0 7.0 7.0 7.050.0 50.0 50.0 70.0 40.0 60.00.0 0.0 10.0 0.0 20.0 1.00.0 -500000.0 500000.0 0.0 0.0 500000.0
Sample Output
3.144.446.2831.4262.83632.243141592.65
Source
Ulm Local 1996
解题报告
表示几何模板党。。。
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#define PI 3.141592653589793using namespace std;struct point{ double x,y;}p1,p2,p3;struct line{ point a,b;};point intersection(line u,line v){ point ret=u.a; double t=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x)) /((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x)); ret.x+=(u.b.x-u.a.x)*t; ret.y+=(u.b.y-u.a.y)*t; return ret;}point circumcenter(point a,point b,point c){ line u,v; u.a.x=(a.x+b.x)/2; u.a.y=(a.y+b.y)/2; u.b.x=u.a.x-a.y+b.y; u.b.y=u.a.y+a.x-b.x; v.a.x=(a.x+c.x)/2; v.a.y=(a.y+c.y)/2; v.b.x=v.a.x-a.y+c.y; v.b.y=v.a.y+a.x-c.x; return intersection(u,v);}double dis(point p1,point p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));}int main(){ while(cin>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y) { point c=circumcenter(p1,p2,p3);// printf("%.2lf %.2lf\n",c.x,c.y); double r=dis(p1,c); //printf("%.2lf\n",r); printf("%.2lf\n",2*PI*r); } return 0;}
0 0
- POJ2242_The Circumference of the Circle(几何/三角形外接圆周长/模板)
- ZOJ 1090 The Circumference of the Circle(计算三角形的外接圆)
- ZOJ-1090-The Circumference of the Circle(计算几何,海伦公式,三角形外接圆半径公式,cout输出小数的一些问题)
- 438 - The Circumference of the Circle【几何】
- 计算几何 The Circumference of the Circle
- The Circumference of the Circle(计算几何)
- (DS1.5.6)POJ 2242 The Circumference of the Circle(一直三个点的坐标,求外接圆的周长)
- HDOJ 1374 The Circumference of the Circle (求外接圆)
- POJ-2242 The Circumference of the Circle-已知三点共圆求周长
- POJ2242_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(计算几何)
- uva 438 - The Circumference of the Circle(几何)
- HDU 1374 The Circumference of the Circle 计算几何
- The Circumference of the Circle
- pku2242The Circumference of the Circle
- zoj1090 The Circumference of the Circle
- 第二十三讲 用户控件与验证码
- Ubuntu下配置VPN
- ubuntu 15.x /CentOS 6.5中安装GO LANG(GO语言)
- Codeforces Round #245 (Div. 2)
- strlen sizeoflengthsize
- POJ2242_The Circumference of the Circle(几何/三角形外接圆周长/模板)
- 第二十四讲 主题与皮肤
- Opencv学习笔记:(2)在VS2012中配置Opencv2.4.9项目
- java猜拳游戏
- Linux chmod命令修改文件与文件夹权限方法
- 第二十五讲 Web Service开发
- netstat命令详细说明
- VS2010中wmain入口函数中使用wprintf输出中文乱码问题
- zTree实现删除树节点