- 绕钉子的长绳子
- 2016-02-14 20:14:18 @
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI acos(-1)
int main(void)
{
int N, r, i;
float length = 0;
float x[100], y[100];
scanf ("%d%d", &N, &r);
for (i=0; i<N; i++) {
scanf ("%f%f", &x[i], &y[i]);
}
for (i=0; i<N-1; i++) {
length += sqrt( (x[i]-x[i+1])*(x[i]-x[i+1]) + (y[i]-y[i+1])*(y[i]-y[i+1]) );
}
length = length + PI*r*2 ;
length += sqrt( (x[N-1]-x[0])*(x[N-1]-x[0]) + (y[N-1]-y[0])*(y[N-1]-y[0]) );
printf ("%.2f", length);
return 0;
}
0 条评论
目前还没有评论...