forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathI.cpp
More file actions
30 lines (25 loc) · 703 Bytes
/
I.cpp
File metadata and controls
30 lines (25 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INTERVAL = int(1e6);
double r1, r2;
double f(double x)
{
return cos(x) * cos(x) * sqrt(r1 * r1 - r2 * r2 + r2 * r2 * cos(x) * cos(x));
}
int main()
{
ios::sync_with_stdio(0);
freopen("twocyl.in", "r", stdin);
freopen("twocyl.out", "w", stdout);
cin >> r1 >> r2;
if (r2 > r1) swap(r1, r2);
double ans = 0;
for (int i = 0; i < INTERVAL; i++)
{
double a = 1. * i / INTERVAL * PI / 2;
double b = 1. * (i + 1) / INTERVAL * PI / 2;
ans += (b - a) / 6 * (f(a) + 4 * f((a + b) / 2) + f(b));
}
cout << fixed << setprecision(6) << ans * 8 * r2 * r2 << endl;
}