#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ElGed_Sevawy ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define el '\n'
#define pi acos(-1)
#define F first
#define S second
#define sz(x) (int)(x).size()
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
ll rand(ll l, ll r){
return uniform_int_distribution<ll>(l, r)(gen);
}
const ll N = 2e5 + 5, M = 1e6 + 5, MOD1 = 1e9 + 7, MOD2 = 1e9 + 9, lg = 21, INF = 2e18 + 5, P1 = 29, P2 = 31;
struct Circle{
ld x, y, r;
};
ld CircleIntersection(Circle A, Circle B) {
ld d, alpha, beta, a1, a2;
ld ans;
d = sqrt((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
if (d > A.r + B.r) ans = 0;
else if (d <= abs(B.r - A.r) && A.r >= B.r)
ans = pi * B.r * B.r;
else if (d <= abs(B.r - A.r) && B.r >= A.r)
ans = pi * A.r * A.r;
else {
alpha = acos((A.r * A.r + d * d - B.r * B.r) / (2 * A.r * d)) * 2;
beta = acos((B.r * B.r + d * d - A.r * A.r) / (2 * B.r * d)) * 2;
a1 = 0.5 * beta * B.r * B.r - 0.5 * B.r * B.r * sin(beta);
a2 = 0.5 * alpha * A.r * A.r - 0.5 * A.r * A.r * sin(alpha);
ans = a1 + a2;
}
return ans;
}
void go() {
Circle c1, c2;
cin >> c1.x >> c1.y >> c1.r >> c2.x >> c2.y >> c2.r;
cout << fixed << setprecision(6) << CircleIntersection(c1, c2) << el;
}
int32_t main() {
ElGed_Sevawy
int tc = 1;
//cin >> tc;
while (tc--)
go();
}
1662H - Boundary | 1676F - Longest Strike |
1057A - Bmail Computer Network | 749C - Voting |
1173A - Nauuo and Votes | 1176E - Cover it |
106A - Card Game | 1076C - Meme Problem |
465B - Inbox (100500) | 844A - Diversity |
1220E - Tourism | 1223B - Strings Equalization |
1339B - Sorted Adjacent Differences | 1331A - Is it rated |
1351C - Skier | 1156A - Inscribed Figures |
691A - Fashion in Berland | 740B - Alyona and flowers |
257B - Playing Cubes | 1490F - Equalize the Array |
1503B - 3-Coloring | 630J - Divisibility |
327B - Hungry Sequence | 1538D - Another Problem About Dividing Numbers |
358B - Dima and Text Messages | 1512E - Permutation by Sum |
311E - Biologist | 1041B - Buying a TV Set |
227C - Flying Saucer Segments | 877E - Danil and a Part-time Job |