Background
There are n cylindrical large nails on the plane, the radius is r, and all the nails form a convex polygon.
Now you're going to surround these nails with a rope, and the rope's diameter is negligible.
Describe
Find out the length of the rope
Format input Format
Line 1th two number: integer N (1<=n<=100) and real R.
The next n lines give the coordinates of the center of N Nails in a counterclockwise order
The absolute value of the coordinate does not exceed 100.
Output format
A number, the length of the rope, exactly 2 digits after the decimal point.
Example 1 Sample Input 1
4 1
0.0 0.0
2.0 0.0
2.0 2.0
0.0 2.0
Sample Output 1
14.28
Limit
Each test point 1s
Tips
If you're using a more complex method of AC, think about whether there's a simpler way.
Find the law, no matter how much n is the distance between his two points plus a circle can draw their own.
#include <iostream>#include<cstring>#include<cstdio>#include<cmath>using namespacestd;Const DoublePi=acos (-1.0);intI,j,n;Doubler,x[101],y[101],ans;intMain () {scanf ("%D%LF",&n,&s); for(i=0; i<n;++i) {scanf ("%LF%LF",&x[i],&Y[i]); if(i>=1) Ans+=sqrt ((x[i]-x[i-1]) * (x[i]-x[i-1]) + (y[i]-y[i-1]) * (y[i]-y[i-1])); if(i==n-1) Ans+=sqrt ((x[i]-x[0]) * (x[i]-x[0]) + (y[i]-y[0]) * (y[i]-y[0])); } ans+=r*2*Pi; printf ("%.2LF", ans);}
Rokua a long rope around a nail