标签:math
One day, KIDx solved a math problem for middle students in seconds! And than he created this problem.

Now, give you the degree of a, b, c, d, please calculate the degree of ∠AED.
There are multiple test cases.
Each case contains one line 4 integers formatted as: "a b c d"
0 ≤ a, b, c, d < 90°.
0 < a+b < 90°, 0 < c+d < 90°.
10 70 60 20 10 70 70 0
20.00 140.00
参考代码:
#include<stdio.h>
#include<math.h>
#define pi acos(-1.0)
int main()
{
double a,b,c,d;
double e;
double AD,BD,BE,DE,AE;
while(~scanf("%lf%lf%lf%lf",&a,&b,&c,&d))
{
a=a*1.0*pi/180;
b=b*1.0*pi/180;
c=c*1.0*pi/180;
d=d*1.0*pi/180;
if(a==0||c==0)
{
printf("0.00\n");
continue;
}
AD=sin(c)/sin(a+b+c);
BD=sin(c+d)/sin(a+b+c+d)-sin(c)/sin(a+b+c);
BE=sin(a+b)/sin(a+b+c+d)-sin(b)/sin(b+c+d);
DE=sqrt((BE*BE+BD*BD+2.0*BE*BD*cos(a+b+c+d)));
AE=sin(c+d)/sin(b+c+d);
e=acos(((1.0*DE*DE+AE*AE-AD*AD)/(2.0*DE*AE)))/pi*180;
if(e<0)
printf("%.2f\n",180-e);
else
printf("%.2f\n",e);
}
return 0;
}版权声明:本文为博主原创文章,随便转载。
ACdream 1203 - KIDx's Triangle(解题报告)
标签:math
原文地址:http://blog.csdn.net/luwhere/article/details/47687013