第一次正式写计算几何,知道了fmod这个东西,知道了外接圆的圆心角的最小份由以三角形三条边每个弦为圆心角的最大公约数。
看带佬的题解:详细的题解
#include <bits/stdc++.h> using namespace std; #define x first #define y second # define rep(i,be,en) for(int i=be;i<=en;i++) # define pre(i,be,en) for(int i=be;i>=en;i--) #define ll long long #define endl "\n" #define LOCAL #define pb push_back #define int long long typedef pair<ll, ll> PII; #define eb emplace_back #define sp(i) setprecision(i) const int N = 2e5 + 10, INF = 0x3f3f3f3f; const double eps = 1e-2, PI = acos(-1.0); struct Point { double x; double y; } p[3]; double len[3], a[3]; double getlen(Point a, Point b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } double gcd(double a, double b) { if (fabs(b) < eps) return a; if (fabs(a) < eps) return b; return gcd(b, fmod(a, b)); } void solve() { for (int i = 0; i < 3; i++) { cin >> p[i].x >> p[i].y; } for (int i = 0; i < 3; i++) { len[i] = getlen(p[i], p[(i + 1) % 3]); } double P = (len[0] + len[1] + len[2]) / 2; double s = sqrt(P * (P - len[0]) * (P - len[1]) * (P - len[2])); double R = len[0] * len[1] * len[2] / (4 * s); for (int i = 0; i < 2; i++) { a[i] = acos(1 - len[i] * len[i] / (2 * R * R)); } a[2] = 2 * PI - a[1] - a[0]; double t = gcd(a[0], gcd(a[1], a[2])); double ans = R * R * PI * sin(t) / t; cout << fixed << setprecision(6) << ans << endl; } signed main() { //#ifdef LOCAL //freopen("data.in.txt","r",stdin); //freopen("data.out.txt","w",stdout); //#endif int __ = 1; //cin >> __; while (__--) { solve(); } return 0; }