This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define piss pair<int, pii>
#define aneh pair<int,vector<bool>>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define cp ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL)
using namespace std;
bool mult = 0, debug = 0;
const int N = 1e6+5;
const ld pi = acos(-1);
struct Circle {
ld x, y, r;
};
void run() {
Circle a, b;
cin >> a.x >> a.y >> a.r >> b.x >> b.y >> b.r;
ld dist = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
// cout << dist << endl;
ld distsq = sqrtl(dist);
// cout << dist << endl;
// cout << acos(0) << endl;
// cout << 2 * b.r * dist << endl;
cout << fixed << setprecision(20);
if (distsq >= a.r + b.r) {
cout << 0 << endl;
return;
}
ld angle2 = acosl(
(b.r * b.r + dist - a.r * a.r) / (2 * b.r * distsq)
) * 2;
// cout << (b.r * b.r + dist - a.r * a.r) / (2 * b.r * distsq) << endl;
ld angle1 = acosl(
(a.r * a.r + dist - b.r * b.r) / (2 * a.r * distsq)
) * 2;
if (isnan(angle2) or (isnan(angle1))) {
int vall = min(a.r, b.r);
cout << vall * vall * pi << endl;
return;
}
// cout << pi << endl;
// cout << angle1 << " " << angle2 << endl;
ld sum1 = (a.r * a.r * sinl(angle1) + b.r * b.r * sinl(angle2)) * 0.5;
// cout << sum1 << endl;
// cout << a.r * a.r * angle1 << " " << b.r * b.r * angle2 << endl;
ld sum2 = (a.r * a.r * angle1 + b.r * b.r * angle2) * 0.5;
// cout << sum2 << endl;
// cout << sum2 << endl;
cout << (long double) sum2 - sum1 << endl;
}
signed main() {
int tc = 1;
if (mult) cin >> tc;
while(tc--) run();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |