标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2186 Accepted Submission(s): 628
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<string> #include<iostream> #include<cstring> #include<cmath> #include<stack> #include<queue> #include<vector> #include<map> #include<stdlib.h> #include<algorithm> #define LL __int64 #define FIN freopen("in.txt","r",stdin) using namespace std; const int MAXN=200+5; const double INF=1e9; const double eps=1e-2; struct node { double x, y; } po[MAXN]; int n; double dis(int a,int b) { return sqrt( (po[a].x-po[b].x) * (po[a].x-po[b].x) + (po[a].y-po[b].y) * (po[a].y-po[b].y) ); } double calc(int a,int b,int c) { double lenA=dis(a,b); double lenB=dis(a,c); double lenC=dis(b,c); double p=(lenA+lenB+lenC)/2; return sqrt(p*(p-lenA)*(p-lenB)*(p-lenC)); } int main() { int kase; scanf("%d",&kase); while(kase--) { scanf("%d",&n); for(int i=0;i<n;i++) scanf("%lf %lf",&po[i].x,&po[i].y); double ans=INF; bool flag=false; for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { for (int k=j+1;k<n;k++) { double tmp=calc(i,j,k); if(fabs(tmp)>=eps) { flag=true; ans=min(ans,tmp); } } } } if (!flag) printf("Impossible\n"); else printf("%.2lf\n",ans); } }
标签:
原文地址:http://www.cnblogs.com/clliff/p/4743550.html