# Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

# Description

Given a triangle ABC, the Extriangles of ABC are constructed as follows:

On each side of ABC, construct a square (ABDE, BCHJ and ACFG in the figure below).

Connect adjacent square corners to form the three Extriangles (AGD, BEJ and CFH in the figure).

The Exomedians of ABC are the medians of the Extriangles, which pass through vertices of the original triangle, extended into the original triangle (LAO, MBO and NCO in the figure. As the figure indicates, the three Exomedians intersect at a common point called the Exocenter (point O in the figure).

This problem is to write a program to compute the Exocenters of triangles.

# Input

The first line of the input consists of a positive integer n, which is the number of datasets that follow. Each dataset consists of 3 lines; each line contains two floating point values which represent the (two -dimensional) coordinate of one vertex of a triangle. So, there are total of (n*3) + 1 lines of input. Note: All input triangles wi ll be strongly non-degenerate in that no vertex will be within one unit of the line through the other two vertices.

# Output

For each dataset you must print out the coordinates of the Exocenter of the input triangle correct to four decimal places.

# Sample Input

2
0.0 0.0
9.0 12.0
14.0 0.0
3.0 4.0
13.0 19.0
2.0 -10.0

# Sample Output

9.0000 3.7500
-48.0400 23.3600


#include <stdio.h>
#include <math.h>

struct Point {
double x, y;
};
struct Line {
Point start, end;
};

int main() {
int test;
scanf("%d", &test);
while (test--) {
Point a, b, c;
scanf("%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);
Line u, v;
u.start = c;
u.end.x = u.start.x - a.y + b.y;
u.end.y = u.start.y + a.x - b.x;
v.start = b;
v.end.x = v.start.x - a.y + c.y;
v.end.y = v.start.y + a.x - c.x;

Point inter = u.start;
double t = ((u.start.x - v.start.x) * (v.start.y - v.end.y) - (u.start.y - v.start.y) * (v.start.x - v.end.x))
/ ((u.start.x - u.end.x) * (v.start.y - v.end.y) - (u.start.y - u.end.y) * (v.start.x - v.end.x));
inter.x += (u.end.x - u.start.x) * t;
inter.y += (u.end.y - u.start.y) * t;

inter.x = fabs(inter.x) < 0.0001 ? 0.0 : inter.x;
inter.y = fabs(inter.y) < 0.0001 ? 0.0 : inter.y;
printf("%.4lf %.4lf\n", inter.x, inter.y);
}
return 0;
}

#### Sicily 1059. Exocenter of a Trian

2013-12-05 22:22:52

#### 1059. Exocenter of a Trian

2014-11-10 20:05:53

#### Sicily 1059. Exocenter of a Triangle

2014-11-06 22:15:04

#### 1059. C语言竞赛(20) PAT乙级真题

2017-12-08 12:14:19

#### 中大SICILY分类

2011-11-03 20:18:21

#### Sicily.1059. Exocenter of a Trian（求垂心，向量旋转）

2012-12-27 16:30:58

#### 中山大学Sicily在线测评系统题目分类

2013-06-26 21:39:40

#### 我的ACM第一步——Sicily 1000

2011-05-07 22:01:00

#### sicily 2015 A New Year Gift

2015-11-10 19:25:09

#### sicily题目分类

2013-09-05 11:52:34