Posted on 2008-11-03 13:03
Hero 阅读(157)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1020 C++ Accepted 0.015 149 KB URAL
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <math.h>
7
8 const double pi = 2.0 * acos( 0.0 ) ;
9 double x[120], y[120] ;
10
11 int inn ;
12 double inr ;
13
14 double fdist( double x1, double y1, double x2, double y2 )
15 {
16 return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;
17 }
18
19 int main()
20 {
21 while( scanf( "%d %lf", &inn, &inr ) != EOF )
22 {
23 for( int i=1; i<=inn; i++ )
24 scanf( "%lf %lf", &x[i], &y[i] ) ;
25
26 double out = 0.0 ;
27 for( int i=1; i<inn; i++ )
28 {
29 out += fdist( x[i], y[i], x[i+1], y[i+1] ) ;
30 }
31
32 out += fdist( x[inn], y[inn], x[1], y[1] ) ;
33
34 out += 2 * pi * inr ;
35
36 printf( "%0.2lf\n", out ) ;
37
38 }
39
40 return 0 ;
41 }