Back Gear | A long rope around the nail

Source: Internet
Author: User
Tags hypot

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.