悬关。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef double d;
d a, b, x1, y01, x2, y2, x3, y3, dis1, dis2, dis3, sum, minn = 2e9;
d dis(d x, d y, d x2, d y2) {
return sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
}
int main() {
scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &a, &b, &x1, &y01, &x2, &y2, &x3, &y3);
for (d p = a; p <= b + 1e-9; p += 1e-7) {
d xd = (1 - p) * x1 + p * x2, yd = (1 - p) * y01 + p * y2, xe = (1 - p) * x2 + p * x3, ye = (1 - p) * y2 + p * y3, xf = (1 - p) * x3 + p * x1, yf = (1 - p) * y3 + y01;
d dis1 = dis(xd, yd, xe, ye), dis2 = dis(xe, ye, xf, yf), dis3 = dis(xf, yf, xd, yd);
sum = (dis1 + dis2 + dis3) * 0.5;
minn = min(minn, sqrt(sum * (sum - dis1) * (sum - dis2) * (sum - dis3)));
}
printf("%.12lf", minn);
return 0;
}