cf B. Vasily the Bear and Fly

http://codeforces.com/contest/336/problem/B

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #include <cmath>
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     int m,r;
10     scanf("%d%d",&m,&r);
11     double sum=0;
12     for(int i=0; i<m; i++)
13     {
14         if(i==0) sum+=2*r*m;
15         else if(i==1) sum+=(2*r+sqrt(2)*r)*(2*m-2);
16         else
17         {
18             sum+=(2*m-2*i)*(((2*i-2)+sqrt(8))*r);
19         }
20     }
21     printf("%lf\n",sum/m/m);
22     return 0;
23 }
View Code

 

posted @ 2014-04-21 11:08  null1019  阅读(185)  评论(0编辑  收藏  举报