1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 #include <cmath> 7 using namespace std; 8 9 #define GI ({int _t; scanf("%d", &_t); _t;}) 10 #define FOR(i, a, b) for (int i=a; i<b; i++) 11 #define REP(i, a) FOR(i, 0, a) 12 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 13 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 14 #define DBG(x) cout << #x << "::" << x << endl; 15 #define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 16 17 18 int main() { 19 long double ax, ay, bx, by, cx, cy; 20 bool first = true; 21 while (cin >> ax >> ay >> bx >> by >> cx >> cy) { 22 //if (first == false) printf("\n"); 23 first = false; 24 //cout << ax << "\t" << ay << "\t" << bx << "\t" << by << "\t" << cx << "\t" << cy << endl; 25 if (ax == bx) { 26 swap(bx, cx); swap(by, cy); 27 } 28 else if (cx == bx) { 29 swap(bx, ax); swap(by, ay); 30 } 31 //cout << ax << "\t" << ay << "\t" << bx << "\t" << by << "\t" << cx << "\t" << cy << endl; 32 long double ma = (ay-by)/(ax-bx); 33 long double mb = (cy-by)/(cx-bx); 34 //DBG(ma); DBG(mb); 35 long double x = (ma*mb*(ay-cy)+mb*(ax+bx)-ma*(bx+cx))/(2*(mb-ma)); 36 long double y = (mb*(by+cy)+(cx-ax)-ma*(ay+by))/(2*(mb-ma)); 37 long double r = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay)); 38 long double c = -2*x; 39 long double d = -2*y; 40 long double e = x*x+y*y-r*r; 41 if (fabs(x)>=0 && fabs(y)>=0) { 42 printf("(x %s %0.3Lf)^2 + (y %s %0.3Lf)^2 = %0.3Lf^2\n", (x>0?"-":"+"), fabs(x), (y>0?"-":"+"), fabs(y), r); 43 printf("x^2 + y^2 %s %0.3Lfx %s %0.3Lfy %s %0.3Lf = 0\n", (c>=0?"+":"-"), fabs(c), (d>=0?"+":"-"), fabs(d), (e>=0?"+":"-"), fabs(e)); 44 } 45 else if (fabs(x)>0) { 46 printf("(x %s %0.3Lf)^2 + y^2 = %0.3Lf^2\n", (x>=0?"-":"+"), fabs(x), r); 47 printf("x^2 + y^2 %s %0.3Lfx %s %0.3Lf = 0\n", (c>=0?"+":"-"), fabs(c), (e>=0?"+":"-"), fabs(e)); 48 } 49 else if (fabs(y)>0) { 50 printf("x^2 + (y %s %0.3Lf)^2 = %0.3Lf^2\n", (y>=0?"-":"+"), fabs(y), r); 51 printf("x^2 + y^2 %s %0.3Lfy %s %0.3Lf = 0\n", (d>=0?"+":"-"), fabs(d), (e>=0?"+":"-"), fabs(e)); 52 } 53 printf("\n"); 54 //cout << x <<"\t" << y << endl; 55 } 56 return 0; 57 }