You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
805 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
struct Point
{
double x, y;
};
double dis(Point x, Point y) { return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y)); }
double cos(double a, double b, double c) { return (b * b + c * c - a * a) / (2 * b * c); }
double dis(Point x, Point a, Point b)
{
double l1 = dis(x, a);
double l2 = dis(x, b);
double l3 = dis(a, b);
if (cos(l1, l2, l3) < 0) return l2;
if (cos(l2, l1, l3) < 0) return l1;
double p = (l1 + l2 + l3) / 2;
double area = sqrt(p * (p - l1) * (p - l2) * (p - l3));
return area * 2 / l3;
}
double dis(double x, Point a, Point b) { return dis({x, 0}, a, b); }
int main()
{
return 0;
}