1020. Rope
来源:互联网 发布:neflix 淘宝账号 编辑:程序博客网 时间:2024/06/06 03:54
1020. Rope
Time limit: 1.0 second
Memory limit: 64 MB
Plotters have barbarously 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.
Problem illustration
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 either in a clockwise or in a counterclockwise order starting from an arbitrary nail. Heads of different nails don’t overlap.
Output
Output 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
output
14.28
#include<iostream>
#include <math.h>
using namespace std;
float a[105][2];
int main(){
int pointnum ;
int r ;
cin>>pointnum;
cin>>r;
double rope = 0;
for(int i = 0 ; i < pointnum ; i++){
cin>>a[i][0];
cin>>a[i][1];
}
for(int i = 0 ; i < pointnum+1 ; i++){
if(i==pointnum){
int t = (a[0][0]-a[i][0])*(a[0][0]-a[i][0]) + (a[0][1]-a[i][1])*(a[0][1]-a[i][1]);
rope = rope + sqrt(abs(t));
}
else{
int t = (a[i+1][0]-a[i][0])*(a[i+1][0]-a[i][0]) + (a[i+1][1]-a[i][1])*(a[i+1][1]-a[i][1]);
rope = rope + sqrt(abs(t));
}
}
rope = rope + 3.14 * 2 * r;
cout<<rope;
return 0;
}
Time limit: 1.0 second
Memory limit: 64 MB
Plotters have barbarously 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.
Problem illustration
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 either in a clockwise or in a counterclockwise order starting from an arbitrary nail. Heads of different nails don’t overlap.
Output
Output 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
output
14.28
#include<iostream>
#include <math.h>
using namespace std;
float a[105][2];
int main(){
int pointnum ;
int r ;
cin>>pointnum;
cin>>r;
double rope = 0;
for(int i = 0 ; i < pointnum ; i++){
cin>>a[i][0];
cin>>a[i][1];
}
for(int i = 0 ; i < pointnum+1 ; i++){
if(i==pointnum){
int t = (a[0][0]-a[i][0])*(a[0][0]-a[i][0]) + (a[0][1]-a[i][1])*(a[0][1]-a[i][1]);
rope = rope + sqrt(abs(t));
}
else{
int t = (a[i+1][0]-a[i][0])*(a[i+1][0]-a[i][0]) + (a[i+1][1]-a[i][1])*(a[i+1][1]-a[i][1]);
rope = rope + sqrt(abs(t));
}
}
rope = rope + 3.14 * 2 * r;
cout<<rope;
return 0;
}
阅读全文
0 0
- 1020. Rope
- ural 1020. Rope
- [timus] 1020. Rope
- ural 1020. Rope(几何)
- Ural-1020. Rope(简单计算几何)
- rope poj
- Verlet rope
- POJ2365 Rope
- BZOJ1507【rope】
- BZOJ1209【rope】
- 2365 Rope
- rope总结
- Rope:理论与实践
- Rope Crisis in Ropeland
- cocos2d cut the rope
- ural 1020 Rope
- hdu_4476_Cut the rope
- POJ 2365 Rope
- 看图说话排序算法之快速排序
- 【笔记】《WebGL编程指南》学习-第6章着色器语言(2-矢量和矩阵)
- 【BZOJ 4563 放棋子】【错排】
- STL之函数适配器
- redis获取异常或者获取不到
- 1020. Rope
- spring源代码-DispatcherServlet
- Linux 输出重定向>和>>的区别是什么?
- 设计模式
- 对java中多态的理解
- oracle数据库连接出现的错误
- centos 安装配置php,nginx
- mysql执行外部sql文件命令
- C#程序结构及基本语法