Calculate the circular area based on the known three-point coordinates.
Using elementary ry knowledge, according to Helen's formula S = SQRT (P-A) (p-B) (p-C )) and the external circle diameter d = a * B * C/(2 S) for direct calculation.
1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #include <numeric> 6 #include <cctype> 7 #include <cmath> 8 #include <algorithm> 9 10 #define PI acos(-1)11 using namespace std;12 13 double calc_dis (double x1, double y1, double x2, double y2) {14 return sqrt ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));15 }16 17 int main () {18 ios :: sync_with_stdio(false);19 double x[3], y[3];20 while (cin >> x[0] >> y[0]) {21 for (int i = 1; i < 3; ++ i) {22 cin >> x[i] >> y[i];23 }24 double a, b, c;25 a = calc_dis (x[0], y[0], x[1], y[1]);26 b = calc_dis (x[0], y[0], x[2], y[2]);27 c = calc_dis (x[2], y[2], x[1], y[1]);28 //cout << a << " " << b << " " << c << endl;29 double p = (a + b + c) / 2;30 double s = sqrt (p * (p - a) * (p - b) * (p - c));31 //cout << "s : " << s << endl;32 double d = a * b * c / (2 * s);33 printf ("%.2f\n", PI * d);34 }35 return 0;36 }
[Poj2242] the circumference of the circle (elementary ry)