题目链接:POJ 2365 Rope

Rope

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7488   Accepted: 2624

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

 

题目大意:

有N颗钉子,每颗钉子半径为R,用一条细线把他们围起来,求细线长度。

大概思路:

①根据每个点的坐标求出两个钉子中心点的距离

②除了中心点的距离,还要加上一颗钉子的周长,一开始我还在想怎么算线接触钉子所占的弧长,其实整体来看,每颗钉子半径相同,细线要围一圈,角度之和为360度,所以加上一个圆周就搞定了!

③半径R要用double, 圆周率要精确到小数点后三位(32ms)小数点后四位(0ms)

AC code(160k 0ms):

 #include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
#define pi 3.1415
using namespace std; const int MAXN = ; double x[MAXN], y[MAXN];
double ans, R;
int N; double s(double x1, double x2, double y1, double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
} int main()
{
scanf("%d%lf", &N, &R);
for(int i = ; i <= N; i++)
{
scanf("%lf %lf", &x[i], &y[i]);
}
for(int i = ; i <= N; i++)
{
ans+=s(x[i], x[i-], y[i], y[i-]);
}
ans+=s(x[], x[N], y[], y[N]);
ans+=(*pi*R);
printf("%.2lf\n", ans);
return ;
}

POJ 2365【YY水题】的更多相关文章

  1. POJ 2365 Rope(水题)

    [题意简述]:给出我们钉子个数与半径,让我们求出缠绕在钉子上的绳子有多长. [分析]:从题目中我们能够看出,绳子长度的和等于每两个钉子的距离的和加上接触在钉子上的绳子的长度,不难发现这部分长度事实上就 ...

  2. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  3. poj 3264 RMQ 水题

    题意:找到一段数字里最大值和最小值的差 水题 #include<cstdio> #include<iostream> #include<algorithm> #in ...

  4. Poj 1552 Doubles(水题)

    一.Description As part of an arithmetic competency program, your students will be given randomly gene ...

  5. 最小费用最大流模板 poj 2159 模板水题

    Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15944   Accepted: 8167 Descr ...

  6. POJ 1837 Balance 水题, DP 难度:0

    题目 http://poj.org/problem?id=1837 题意 单组数据,有一根杠杆,有R个钩子,其位置hi为整数且属于[-15,15],有C个重物,其质量wi为整数且属于[1,25],重物 ...

  7. POJ - 3090 gcd水题

    大概题意就是求\(1 \le i,j \le n\)的\(gcd(i,j) = 1\)的个数+2(对于0的特判) 正解应该是欧拉函数或者高逼格的莫比乌斯反演 但数据实在太水直接打表算了 /*H E A ...

  8. POJ 3256 DFS水题

    枚举点 每次都搜一遍 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...

  9. POJ 1654 Area(水题)

    题目链接 卡了一下精度和内存. #include <cstdio> #include <cstring> #include <string> #include &l ...

随机推荐

  1. hibernate框架配置文件详解

    1 orm元数据配置文件(映射文件) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hib ...

  2. 【程序员技术练级】学习一门脚本语言 python(二)遍历本地文件系统

    这篇将讲述怎么使用python来遍历本地文件系统,并把文件按文件大小从小到大排序的一个小例子 在这个例子中,主要会用到python内置的和OS模块的几个函数: os.walk() : 该方法用来遍历指 ...

  3. TOJ 4119 Split Equally

    描述 Two companies cooperatively develop a project, but they don’t like working with one another. In o ...

  4. Jenkins+Postman+Newma+Xmysql之API全自动化测试

    第一章 前期准备:各种安装配置介绍 ①Postman安装及使用 ②Newman 安装及使用 ③Xmysql 安装及使用 ④Jenkins安装及配置 1.postman 安装及使用 1.1.postma ...

  5. poj 1028 Web Navigation

    Web Navigation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31088   Accepted: 13933 ...

  6. 【ubuntu】更换下载源

    ubuntu,我们在使用apt新装软件的时候,会使用官方的网站去下载软件,但是会因为国内的转接点太多,而导致下载的速度非常慢 ,我们可以通过换成一些中间的节点来进行下载,比如阿里源,中科大源,清华源等 ...

  7. 05.if结构

    分支结构:if  if-else 选择结构:if else-if switch-case 循环结构:while do-while for foreach if语句 语法: if(判断条件) { //要 ...

  8. hello2详解

    1.GreetingServlet.java(显示问候页面表单) 此servlet重写该doGet方法,实现GETHTTP方法.servlet显示一个简单的HTML问候表单,其提交按钮就像hello1 ...

  9. Java Socket, DatagramSocket, ServerSocketChannel io代码跟踪

    Java Socket, DatagramSocket, ServerSocketChannel这三个分别对应了,TCP, udp, NIO通信API封装.JDK封装了,想跟下代码,看下具体最后是怎么 ...

  10. python数据类型(数字\字符串\列表)

    一.基本数据类型——数字 1.布尔型 bool型只有两个值:True和False 之所以将bool值归类为数字,是因为我们也习惯用1表示True,0表示False. (1)布尔值是False的各种情况 ...