Advertisement
Guest User

B

a guest
Aug 9th, 2013
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <cstdio>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. int m, r;
  11. scanf("%d%d", &m, &r);
  12.  
  13. double result = 0;
  14. for (int i = 0; i < m; ++i) {
  15. result += 2;
  16. if (i > 0) result += (2 + sqrt(2.));
  17. if (i + 1 < m) result += (2 + sqrt(2.));
  18.  
  19. if (i > 0) {
  20. double v = i - 1;
  21. result += v * (v + 1);
  22. result += 2. * sqrt(2.) * v;
  23. }
  24. if (i + 1 < m) {
  25. double v = m - 2 - i;
  26. result += v * (v + 1);
  27. result += 2. * sqrt(2.) * v;
  28. }
  29. }
  30.  
  31. printf("%.10lf\n", result * r / m / m);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement