#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();
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值