Centre of symmetry

点击打开链接

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

Sample Output

0.500 0.500
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;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值