- 绕钉子的长绳子
- 2014-12-05 16:30:40 @
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
struct Point{
double x;
double y;
};
Point point[100];
const double PI=3.1415926;
double destination(Point p1,Point p2){
return (double)sqrt(pow((p1.x-p2.x),2)+pow((p1.y-p2.y),2));
}
int main(){
int N;double R;
double sum=0;
cin>>N;
cin>>R;
for(int i=0;i<N;i++){
cin>>point[i].x;
cin>>point[i].y;
}
for(int k=0;k<N-1;k++){
sum+=destination(point[k],point[k+1]);
}
sum+=destination(point[0],point[N-1]);
sum+=2.0*PI*R;
cout<<sum;
return 0;
}
1 条评论
-
twd2 LV 9 MOD @ 2014-12-06 21:48:54
请正确地发布源代码
- 1