标签:des style blog http java color
Time
Limit: 10000/5000 MS (Java/Others) Memory Limit:
65536/32768 K (Java/Others)
Total Submission(s):
28373 Accepted Submission(s):
7417
1 #include"iostream" 2 #include"algorithm" 3 #include"cmath" 4 #include"cstdio" 5 using namespace std; 6 #define min(a,b) ((a)>(b))?(b):(a) 7 struct point 8 { 9 double x,y; 10 }a[100003]; 11 bool cmp(const point &a,const point &b) 12 { 13 if(a.x==b.x) 14 return a.y<b.y; 15 return a.x<b.x; 16 } 17 double dis(point a,point b) 18 { 19 return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)); 20 } 21 double S(point a[],int n) 22 { 23 double m=0xffffff; 24 if(n==2) 25 return dis(a[0],a[1]); 26 for(int i=0;i<n-2;i++) 27 { 28 m=min(m,min(dis(a[i],a[i+1]),min(dis(a[i],a[i+2]),dis(a[i+1],a[i+2])))); 29 } 30 return m; 31 } 32 int main() 33 { 34 int n; 35 while(scanf("%d",&n),n) 36 { 37 for(int i=0;i<n;i++) 38 { 39 scanf("%lf%lf",&a[i].x,&a[i].y); 40 } 41 sort(a,a+n,cmp); 42 printf("%.2lf\n",S(a,n)/2); 43 } 44 return 0; 45 }
标签:des style blog http java color
原文地址:http://www.cnblogs.com/767355675hutaishi/p/3700174.html