#include<iostream>
using namespace std;
#define N 1000001
struct node{
double x,y;
}p[N];
int n;
void cal_c(){
node u,v;
double area=0,tx=0,ty=0,temp;
u.x=p[0].x;u.y=p[0].y;
for(int i=1;i<n;i++){
v.x=p[i].x;
v.y=p[i].y;
temp=(u.x*v.y-v.x*u.y);
area+=temp;
tx+=(u.x+v.x)*temp;
ty+=(u.y+v.y)*temp;
u.x=v.x;u.y=v.y;
}
temp=(u.x*p[0].y-u.y*p[0].x);
area+=temp;
tx+=(u.x+p[0].x)*temp;
ty+=(u.y+p[0].y)*temp;
tx=tx/(3.0*area);
ty=ty/(3.0*area);
printf("%.2lf %.2lf\n",tx,ty);
}
int main(void){
int t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
cal_c();
}
}
杂
最新推荐文章于 2024-04-30 21:51:33 发布