#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define INF 0.0000001
const int N = 10010;
struct point
{
double x, y;
point() :x(0), y(0){}
}p[N];
int main()
{
int ncase;
scanf("%d", &ncase);
while (ncase--)
{
int n;
double result = 0;
point ans;
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%lf%lf", &p[i].x, &p[i].y);
for (int i = 1; i <= n; ++i)
{
double temp = (p[i % n].x * p[i - 1].y - p[i % n].y * p[i - 1].x) / 2.0;
result += temp;
ans.x += temp * (p[i % n].x + p[i - 1].x) / 3.0;
ans.y += temp * (p[i % n].y + p[i - 1].y) / 3.0;
}
if (fabs(result - 0) < INF)
puts("0.000 0.000");
else
printf("%.3lf %.3lf\n", fabs(result), (ans.x + ans.y) / result); //result取绝对值
}
return 0;
}
南阳理工大学oj第三题
最新推荐文章于 2021-12-06 19:14:28 发布