记录编号 238861 评测结果 WWWWTTTWWWWWTTTWWWWWTTTWWWWWTTT
题目名称 最小距离和 最终得分 0
用户昵称 Gravatarasddddd 是否通过 未通过
代码语言 C++ 运行时间 69.765 s
提交时间 2016-03-19 15:01:48 内存使用 0.47 MiB
显示代码纯文本
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#define maxn 11000
using namespace std;
struct point{
	double x,y;
	point(double x=0,double y=0):x(x),y(y){
	};
};
point operator -(point a,point b){
	return point(a.x-b.x,a.y-b.y);
}
typedef point Vector;
double cross(Vector a,Vector b){
	return a.x*b.y-b.x*a.y;
}
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double length(Vector a){
	return sqrt(dot(a,a));
}
double diseg(point p,point a,point b){
	point v1=b-a,v2=p-a;
	return fabs(cross(v1,v2))/length(v1);
}
point asd[maxn];
int main(){
	freopen("space.in","r",stdin);
	freopen("space.out","w",stdout);
    int n;
	cin>>n;
	double minn=99999999;
	for(int i=0;i<n;i++){
		cin>>asd[i].x>>asd[i].y;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			double ans=0;
			for(int k=0;k<n;k++){
				if(k!=i&&k!=j)
				ans+=diseg(asd[k],asd[i],asd[j]);
			}
			if(ans<minn)
			minn=ans;
		}
	}
	cout.precision(2);
	cout<<minn;
}