Description
If we are given a point and the centre of symmetry, we can get the symmetric point easily, but now, if I give you N original points and their symmetric point, can you find the centre of symmetry?
Input
The first line contains a number T denotes the number of test cases.
For each test case,
In the first line, you will get an integer N (1<=N<=1000) indicate there are N pairs of points.
In the following 2*N lines, each contain a pair of real numbers, which describes the coordinates of the points.All the coordinates are in the range of [-2000000000,2000000000].
A point isn't necessarily adjacent to its symmetric point.
Output
For each test case, you should output a pair of real number, describes the coordinate of the centre of symmetry. Both the number should round to 3 digital. You may assume the centre of symmetry is always existed.
Sample Input
2
1
0 0
1 1
2
0 0
1 1
2 0
1 -1
1
0 0
1 1
2
0 0
1 1
2 0
1 -1
Sample Output
0.500 0.500
1.000 0.000
1.000 0.000
水题
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
double x,y,x1,y1,sum1,sum2;
int i,j,k,l,m,n;
scanf("%d",&m);
while(m--)
{
scanf("%d",&n);
sum1=0;
sum2=0;
for(i=1;i<=n*2;i++)
{
scanf("%lf%lf",&x,&y);
sum1+=x;
sum2+=y;
}
printf("%.3lf %.3lf\n",sum1/n/2,sum2/2/n);
}
return 0;
}