我希望你是我独家记忆

一段永远封存的记忆,随风而去
posts - 263, comments - 31, trackbacks - 0, articles - 3
   :: 首页 :: 新随笔 ::  :: 聚合  :: 管理

URAL1020

Posted on 2008-11-03 13:03 Hero 阅读(142) 评论(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         forint i=1; i<=inn; i++ )
24             scanf( "%lf %lf"&x[i], &y[i] ) ;
25 
26         double out = 0.0 ;
27         forint 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 }

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理