Created
August 10, 2013 05:46
-
-
Save hhc0null/6199227 to your computer and use it in GitHub Desktop.
AOJ0010
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <iostream> | |
#include <iomanip> | |
#include <stack> | |
#include <list> | |
#include <vector> | |
using namespace std; | |
int main(void) { | |
int num; | |
double x[3], y[3], a1, a2, b1, b2, c1, c2, px, py, r; | |
cin >> num; | |
for(int i = 0; i < num; i++) { | |
cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2]; | |
a1 = 2*(x[1]-x[0]); | |
b1 = 2*(y[1]-y[0]); | |
c1 = (x[0]*x[0] - x[1]*x[1]) + (y[0]*y[0] - y[1]*y[1]); | |
a2 = 2*(x[2]-x[0]); | |
b2 = 2*(y[2]-y[0]); | |
c2 = (x[0]*x[0] - x[2]*x[2]) + (y[0]*y[0] - y[2]*y[2]); | |
px = (b1*c2-b2*c1)/(a1*b2-a2*b1); | |
py = (c1*a2-c2*a1)/(a1*b2-a2*b1); | |
r = sqrt(pow(px-x[0],2)+pow(py-y[0],2)); | |
cout << fixed << setprecision(3) << px << " " << py << " " << r << endl; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment