博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj----1090---The Circumference of the Circle---数学几何
阅读量:7001 次
发布时间:2019-06-27

本文共 2051 字,大约阅读时间需要 6 分钟。

The Circumference of the Circle

Time Limit: 2 Seconds      
Memory Limit: 65536 KB

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 Specification

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 Specification

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
1 #include
2 #include
3 #define IP 3.141592653589793 4 int main() 5 { 6 double x1,x2,x3,y1,y2,y3; 7 while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF) 8 { 9 double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));10 double b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));11 double c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));12 double p=(a+b+c)/2;13 double s=sqrt(p*(p-a)*(p-b)*(p-c));14 double r=a*b*c/(4*s);15 printf("%.2lf\n",IP*2*r);16 }17 }
View Code

解一:三角函数求解半径r

根据余弦定理:c^2=a^2+b^2-2abcosC

根据正弦定理:c/sinC=2r

sinC*sinC+cosC*cosC=1

(c/2)^2+((a*a+b*b-c*c)/(2*a*b))^2=1

解2:面积公式求解半径

三角形的外接圆半径:r=abc/4s

根据海伦公式计算面积:s=sqrt(p(p-a)(p-b)(p-c))

p=(a+b+c)/2

转载于:https://www.cnblogs.com/zsj-93/p/3176663.html

你可能感兴趣的文章
thinkphp中cookie和session中操作数组的方法
查看>>
rman备份OBSOLETE和EXPIRED参数来历及区别
查看>>
NewLife.Redis基础教程
查看>>
BlockingQueue(阻塞队列)详解
查看>>
Hystrix快速入门
查看>>
十大励志电影
查看>>
在Sql语句中使用正则表达式来查找你所要的字符
查看>>
18种最实用的网站推广方法大全
查看>>
浅谈C/C++中的typedef和#define
查看>>
浅谈C/C++中的指针和数组(一)
查看>>
这该死的数字化生活
查看>>
matlab练习程序(圆柱投影)
查看>>
需要谨记的产品设计原则
查看>>
checkbox实现单选多选
查看>>
billing是如何的拆分的?
查看>>
Lua 迭代器与closure
查看>>
mybatis_helloworld(2)_源码
查看>>
完整部署CentOS7.2+OpenStack+kvm 云平台环境(3)--为虚拟机指定固定ip
查看>>
BLE 广播数据解析
查看>>
Oracle用户密码过期和用户被锁解决方法【转】
查看>>