比赛 |
ZLXSCDay1 |
评测结果 |
WWWWTTTWWWWWTTTWAWWWTTTWWWWWTTT |
题目名称 |
最小距离和 |
最终得分 |
3 |
用户昵称 |
asddddd |
运行时间 |
69.625 s |
代码语言 |
C++ |
内存使用 |
0.48 MiB |
提交时间 |
2016-03-18 20:04:54 |
显示代码纯文本
#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<<minn;
}