fork(1) download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double x1, y1, x2, y2, x3, y3;
  8. while(scanf("%lf %lf", &x1, &y1)==2)
  9. {
  10. if(x1==0.0 && y1==0.0) break;
  11. scanf("%lf %lf %lf %lf", &x2, &y2, &x3, &y3);
  12. double dis = (x1-x2)*(y2-y3) - (x2-x3)*(y1-y2);
  13. cout<<dis<<endl;
  14. if(dis==0.0)
  15. {
  16. printf("Impossible\n");
  17. continue;
  18. }
  19. double A, B, H, K, calc1, calc2, X1, Y1, X2, Y2;
  20. A = fabs((x1*x1) + (y1*y1) - (x2*x2) - (y2*y2));
  21. B = fabs((x2*x2) + (y2*y2) - (x3*x3) - (y3*y3));
  22. X1 = fabs(x1-x2);
  23. Y1 = fabs(y1-y2);
  24. X2 = fabs(x2-x3);
  25. Y2 = fabs(y2-y3);
  26. H = (A*Y2) - (B*Y1);
  27. calc1 = 2.0 * ((X1*Y2)-(X2*Y1));
  28. H = H/(calc1);
  29. K = (B - (2.0*H*X2))/Y2;
  30. K = K/2.0;
  31. cout<<H<<' '<<K<<endl;
  32. double disone, distwo, disthree;
  33. disone = sqrt((x1-H)*(x1-H) + (y1-K)*(y1-K));
  34. distwo = sqrt((x2-H)*(x2-H) + (y2-K)*(y2-K));
  35. disthree = sqrt((x3-H)*(x3-H) + (y3-K)*(y3-K));
  36. cout<<disone<<' '<<distwo<<' '<<disthree<<endl;
  37. if(disone==distwo && distwo==disthree)
  38. {
  39. cout<<H<<' '<<K<<endl;
  40. }
  41. else
  42. printf("Impossible\n");
  43.  
  44. }
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 2728KB
stdin
Standard input is empty
stdout
Standard output is empty