반응형
https://www.algospot.com/judge/problem/read/MOON
#include <stdio.h>
#include <math.h>
#define M_PI 3.14159265358979323846
double getAngle(double a, double b, double c)
{
return acos((a * a + b * b - c * c) / (2 * a * b));
}
double getSize(double a, double b, double c)
{
double s = (a + b + c) / 2;
return sqrt(s * (s - a) * (s - b) * (s - c));
}
int main()
{
int CASE;
for (scanf("%d", &CASE); CASE > 0; CASE--)
{
double M, S, C;
double MOON, T_SHAWDOW, T_MOON, TRIANGLE;
scanf("%lf %lf %lf", &M, &S, &C);
TRIANGLE = getSize(M, S, C);
MOON = M * M * M_PI;
T_MOON = MOON * (getAngle(M, C, S) / (2 * M_PI));
T_SHAWDOW = S * S * M_PI * (getAngle(S, C, M) / (2 * M_PI));
printf("%.3lf\n", MOON - (T_MOON + T_SHAWDOW - TRIANGLE) * 2);
}
return 0;
}
반응형