1 #include<iostream> 2 #include<stdlib.h> 3 #include<cmath> 4 #include<stdio.h> 5 using namespace std; 6 int n; 7 typedef struct 8 { 9 double x; 10 double y; 11 }Point; 12 13 Point p[110],s[110]; 14 15 int top; 16 17 double Mul(Point a, Point b, Point c) 18 { 19 return (b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x); 20 } 21 22 double dis(Point a, Point b) 23 { 24 return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); 25 } 26 27 28 int cmp(const void *a, const void *b) 29 { 30 Point c = *(Point *)a; 31 Point d = *(Point *)b; 32 double k = Mul(p[0], c, d); 33 if(k < 0 || (!k && dis(c, p[0]) > dis(d, p[0]))) 34 return 1; 35 return -1; 36 } 37 38 39 void Con() 40 { 41 int i; 42 for(i = 1; i < n; i++) 43 { 44 Point temp; 45 if(p[i].y < p[0].y || (p[i].y == p[0].y && p[i].x < p[0].x)) 46 { 47 temp = p[i]; 48 p[i] = p[0]; 49 p[0] = temp; 50 } 51 } 52 qsort(p+1, n - 1, sizeof(p[0]), cmp); 53 s[0] = p[0]; 54 s[1] = p[1]; 55 s[2] = p[2]; 56 top =2; 57 58 for(i = 3; i < n; i++)//congsan 59 { 60 while(top >= 2 && Mul(s[top - 1], s[top], p[i]) <= 0) 61 top--; 62 top++; 63 s[top] = p[i]; 64 } 65 } 66 67 68 int main() 69 { 70 71 while(cin>>n,n) 72 { 73 int i; 74 for(i = 0; i < n; i++) 75 { 76 cin>>p[i].x>>p[i].y; 77 } 78 if(n == 1) 79 { 80 cout<<"0.00"<<endl; 81 continue; 82 } 83 84 else if(n == 2) 85 { 86 printf("%.2lf\n",dis(p[0],p[1])); 87 continue; 88 } 89 Con(); 90 double count = 0; 91 for(i = 0; i < top; i++) 92 { 93 count += dis(s[i],s[i+1]); 94 } 95 count += dis(s[top],s[0]); 96 printf("%.2lf\n",count); 97 98 } 99 return 0; 100 }