题目大意:给出凸多边形上点(注意!不是按照一定顺序给出,可能是乱序),求该凸多边形的质心,另外当凸多边形顶点数小于3,结束输入。
解题策略:凸多边形顶点无序给出—>求出凸包(使凸多边形以顶点逆序保存)—>求凸包质心(由于二维几何平面质量均匀)—>求凸包重心。
求凸多边形重心,参看链接:http://www.cnblogs.com/jbelial/archive/2011/08/08/2131165.html
/*
UVA 10002 Center of Masses
AC by J_Dark
ON 2013/5/6 20:31
Time 0.305s 跑得好快 = =
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
/
struct point{
double x, y;
point(double a, double b){
x = a;
y = b;
}
double Distance(point t){
return sqrt((x-t.x)*(x-t.x) + (y-t.y)*(y-t.y));
}
};
vector<point> p;
v