Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <cstdio>
- using namespace std;
- int main() {
- int m, r;
- scanf("%d%d", &m, &r);
- double result = 0;
- for (int i = 0; i < m; ++i) {
- result += 2;
- if (i > 0) result += (2 + sqrt(2.));
- if (i + 1 < m) result += (2 + sqrt(2.));
- if (i > 0) {
- double v = i - 1;
- result += v * (v + 1);
- result += 2. * sqrt(2.) * v;
- }
- if (i + 1 < m) {
- double v = m - 2 - i;
- result += v * (v + 1);
- result += 2. * sqrt(2.) * v;
- }
- }
- printf("%.10lf\n", result * r / m / m);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement