CF1C求助
  • 板块学术版
  • 楼主Tzs_yousa
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/5/7 18:56
  • 上次更新2023/10/28 01:58:28
查看原帖
CF1C求助
453100
Tzs_yousa楼主2022/5/7 18:56

不知道为什么数学题会TLE呜呜,求大佬帮帮

#include <bits/stdc++.h>
using namespace std;
const double phi = acos(-1.0);
const double EPS = 1e-3;
struct node{
    double x, y;
}e[5];
double ask_L(int i, int j)
{
    return sqrt( (e[i].x - e[j].x) * (e[i].x - e[j].x) + (e[i].y - e[j].y) * (e[i].y - e[j].y));
}
double ask_S(double a, double b, double c)
{
	double p = (a + b + c) / 2.0;
	double ans = sqrt(p * (p - a) * (p - b) * (p - c));
	return ans;
}
double gcd(double a, double b) 
{
    if(fabs(b) < EPS)
        return a;
    if(fabs(a) < EPS)
        return b;
    return gcd(b, fmod(a, b));
}
int main()
{
    for (int i = 1; i <= 3; i++) scanf("%lf%lf", &e[i].x, &e[i].y);
    double a = ask_L(1, 2), b = ask_L(1, 3), c = ask_L(2, 3);
    double S = ask_S(a, b, c);
	double r = a * b * c / (4.0 * S);
    double A = acos(1 - a * a / (2 * r * r)); 
    double B = acos(1 - b * b / (2 * r * r)); 
    double C = 2 * phi - A - B;
    double e = gcd(gcd(A, B), C);
    printf("%.6lf", phi * r * r * sin(e) / e);
    return 0;
}
2022/5/7 18:56
加载中...