Background 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.
Description Description
Find out the length of the rope
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.
Input Sample:
4 10.0 0.02.0 0.02.0 2.00.0 2.0
Sample output:
14.28
Topic Analysis:
I don't usually send this water question (what do you do?) , but I wa a point in this problem. I am puzzled ...
#include <iostream> #include <cstdio> #include <cstring>#definePi 3.141592653intMain () {DoubleCircum,r,x0,y0,x1,y1,x,y; intN,i; scanf ("%d%lf",&n,&R); scanf ("%LF%LF",&x0,&y0); X1=x0; Y1=y0; for(i=1; I {scanf ("%LF%LF",&x,&y); Circum+=hypot (x-x1,y-y1); X1=x; Y1=y; } circum+=hypot (x-x0,y-y0); Circum+=pi*2*s; printf ("%.2LF", circum); return 0; }
Back Gear | A long rope around the nail