Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 32768/32768 K
(Java/Others)
Total Submission(s): 1125 Accepted
Submission(s): 325
1 #include <iostream>
2 #include <iomanip>
3 using namespace std;
4 struct point{
5 double x,y;
6 }P[105];
7 double getS(point a,point b,point c) //叉积求面积
8 {
9 return ((b.x - a.x) * (c.y - a.y) - (b.y - a.y)*(c.x - a.x))/2;
10 }
11 int main()
12 {
13 int T,N;
14 cin>>T;
15 cout<<setiosflags(ios::fixed)<<setprecision(2);
16 while(T--){
17 cin>>N;
18 bool flag = false;
19 double minS=999999999;
20 for(int i=1;i<=N;i++)
21 cin>>P[i].x>>P[i].y;
22 for(int i=1;i<=N;i++)
23 for(int j=1;j<=N;j++)
24 if(i!=j)
25 for(int k=1;k<=N;k++)
26 if(k!=i && k!=j){
27 double t = getS(P[i],P[j],P[k]);
28 if(t<0) t=-t;
29 if(t<minS && t!=0){
30 minS=t;
31 flag = true;
32 }
33 }
34 if(flag)
35 cout<<minS<<endl;
36 else
37 cout<<"Impossible"<<endl;
38 }
39 return 0;
40 }
Freecode : www.cnblogs.com/yym2013
原文:http://www.cnblogs.com/yym2013/p/3535170.html