数学问题--POJ 2242
该题纯属数学问题,已知不共线的三点,求这三点构成圆周周长通过这三点可求得三边a,b,c。利用余弦定理求得A的余弦值,再根据圆的性质之一:
一段弧所对圆周角均相等,即可转化到该圆以a为直角边以d为斜边的直角三角形 则d=a/cosA C=PI*d
1 #include<iostream>
2 #include<math.h>
3 #define PI 3.141592653589793
4 using namespace std;
5 int main()
6 {
7 double x0,x1,x2,y0,y1,y2,a,b,c,cosA;
8 while(scanf("%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2)!=EOF)
9 {
10 a=sqrt((y0-y1)*(y0-y1)+(x0-x1)*(x0-x1));
11 b=sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2));
12 c=sqrt((y0-y2)*(y0-y2)+(x0-x2)*(x0-x2));
13 cosA=(b*b+c*c-a*a)/(2*b*c);
14 printf("%.2lf\n",PI*a/sqrt(1-cosA*cosA));
15 }
16 return 0;
17 }