poj 2365 Rope
来源:互联网 发布:软件购销合同书范本 编辑:程序博客网 时间:2024/06/07 07:10
题目链接:http://poj.org/problem?id=2365View Code
题意:给出钉子数量和半径,并顺时针给出每个钉子的位置,求绕过钉子的绳子的长度。
分析:绕过钉子的长度正好是一个钉子的周长,然后加上该多边形的周长即为答案。(虽然我是看案例猜出来的)(输出时要用%.2f,因此wa了N发。)
http://book.51cto.com/art/200901/106880.htm
代码:
#include<cstdio>#include<cmath>#include<cstring>#include<queue>#include<stack>#include<cstdlib>#include<iomanip>#include<string>#include<vector>#include<map>#include<string>#include<iostream>#include<algorithm>using namespace std;#define INF 0x3f3f3f3ftypedef long long ll;#define Max(a,b) (a>b)?a:b#define lowbit(x) x&(-x)int main(){ int n; double len=0,r,x[105],y[105]; cin>>n>>r; for(int i=0;i<n;i++) { cin>>x[i]>>y[i]; if(i>0) { len+=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1])); } if(i==n-1) len+=sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0])); } len+=2*r*acos(-1.0); printf("%.2f\n",(float)len); //cout<<setprecision(4)<<len<<endl;}
0 0
- POJ 2365 Rope
- POJ 2365Rope
- POJ 2365 Rope(水题)
- poj 2365 Rope
- POJ 2365 Rope G++
- rope poj
- POJ 2365 Rope(计算几何)
- 2365 Rope
- poj解题报告——poj 2365 Rope
- 【#define PI acos(-1.0)】【非凸包】poj 2365 Rope
- pku 2365 Rope 解题报告
- Verlet rope
- POJ2365 Rope
- BZOJ1507【rope】
- BZOJ1209【rope】
- rope总结
- 1020. Rope
- hdu-1392 Surround the Trees && poj Rope (简单凸包)
- PAT 团体程序设计天梯赛-练习集 L2-006. 树的遍历
- 导入支付宝插口?
- HDU 2059 龟兔赛跑 (dp) 代码+注释
- HDU 1028 Ignatius and the Princess III
- BZOJ 3173: [Tjoi2013]最长上升子序列
- poj 2365 Rope
- Hive分析窗口函数(五) GROUPING SETS,GROUPING__ID,CUBE,ROLLUP
- poj 2366 Sacrament of the sum
- poj 2367 Genealogical tree
- Apple Mach-O Linker (ld) Error Group
- poj 2368 Buttons
- poj 2369 Permutations
- poj 2370 Democracy in danger
- jmeter通过jmeter-plugins、jconsole对系统资源进行监控