2365 Rope
来源:互联网 发布:php中使用url传递数组 编辑:程序博客网 时间:2024/05/17 10:25
Description
Plotters have barberically hammered N nails into an innocent plane shape, so that one can see now only heads. Moreover, pursuing their mean object, they have hammered all the nails into the vertices of a convex polygon. After that they…it is awful… have roped off the nails, so that the shape felt upset (the rope was very thin). They’ve done it as it is shown in the figure.
Your task is to find out a length of the rope.
Input
There two numbers in the first line of the standard input: N — a number of nails (1 <= N <= 100), and a real number R — a radius of heads of nails. All the heads have the same radius. Further there are N lines, each of them contains a pair of real coordinates (separated by a space) of centers of nails. An absolute value of the coordinates doesn’t exceed 100. The nails are described in a clockwise order starting from an arbitrary nail. Heads of different nails don’t adjoin.
Output
The standard output should contain in its only line a real number with two digits precision (after a decimal point) — a length of the rope.
Sample Input
4 1
0.0 0.0
2.0 0.0
2.0 2.0
0.0 2.0
Sample Output
14.28
Source
Ural State University Internal Contest October’2000 Junior Session
/*绳子长度等于N个圆心距离和加上钉子周长*/#include<iostream>#include<iomanip>#include<math.h>using namespace std;#define PI 3.1415926535898struct nail { double x, y;}coor[100];int main(){ int N; double R, length = 0; cin >> N >> R; for (int i = 0; i < N; i++) { cin >> coor[i].x >> coor[i].y; } for (int i = 0; i < N - 1; i++) { length += sqrt((coor[i + 1].x - coor[i].x)*(coor[i + 1].x - coor[i].x) + (coor[i + 1].y - coor[i].y)*(coor[i + 1].y - coor[i].y)); } length += sqrt((coor[0].x - coor[N - 1].x)*(coor[0].x - coor[N - 1].x) + (coor[0].y - coor[N - 1].y)*(coor[0].y - coor[N - 1].y)); length += 2*R*PI; cout << fixed << setprecision(2) << length << endl; return 0;}
- 2365 Rope
- POJ 2365 Rope
- POJ 2365Rope
- POJ 2365 Rope(水题)
- poj 2365 Rope
- POJ 2365 Rope G++
- pku 2365 Rope 解题报告
- POJ 2365 Rope(计算几何)
- 【#define PI acos(-1.0)】【非凸包】poj 2365 Rope
- poj解题报告——poj 2365 Rope
- rope poj
- Verlet rope
- POJ2365 Rope
- BZOJ1507【rope】
- BZOJ1209【rope】
- rope总结
- 1020. Rope
- Rope:理论与实践
- Vector容器
- MOOC清华《面向对象程序设计》第4章:虚函数实验
- ubuntu14.04下部署smokeping监控软件
- centos7 部署全过程记录
- C/C++连接mysql以及CURD
- 2365 Rope
- Tomcat |Tomcat启动超时错误
- 创建scott的案例表代码
- acm学习
- mmm bionic avoid debug(fork)
- 算法系列——二叉搜索树和双向链表(剑指offer)
- 线段树——Luogu3870/BZOJ1230 [Usaco2008 Nov]lites 开关灯
- 微信小程序——获取用户unionId
- scala中循环不建议使用while和do...while,而建议使用递归