acdream.18.KIDx's Triangle(数学推导)

KIDx's Triangle

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

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

acdream.18.KIDx's Triangle(数学推导)

Now, give you the degree of a, b, c, d, please calculate the degree of ∠AED.

Input

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°.

Output

For each test case, output the answer in one line, rounded to 2 decimal places.

Sample Input

10 70 60 20
10 70 70 0

Sample Output

20.00
140.00
 #include<stdio.h>
#include<math.h>
#define pi 3.141592653589793
double a , b , c , d ;
double BE , BD , DE , bata , AD , AE ; inline double f (double k)
{
return 1.0 * k * pi / ;
} int main ()
{
freopen ("a.txt" , "r" , stdin ) ;
while (~ scanf ("%lf%lf%lf%lf" , &a , &b , &c , &d)) {
if (a == ) {
printf ("0.00\n") ;
continue ;
}
AD = sin (f(c)) / sin (f(a + b + c)) ;
BD = sin (f(c + d)) / sin (f(a + b + c + d)) - sin (f(c)) / sin (f(a + b + c)) ;
BE = sin (f(a + b)) / sin (f(a + b + c + d)) - sin (f(b)) / sin (f(b + c + d)) ; DE = sqrt (1.0 * (BE * BE + BD * BD + * BE * BD * cos (f(a + b + c + d)))) ;
AE = sin (f(c + d)) / sin (f(b + c + d)) ;
bata = acos (1.0 * (DE * DE + AE * AE - AD * AD) / (2.0 * DE * AE)) * / pi;
// printf ("DE = %.2f , EF = %.2f , DF = %.2f\n" , DE , EF , DF) ;
// printf ("bata = %.2f\n" , bata * 180 / pi) ;
if (bata < )
printf ("%.2f\n" ,180.0 - bata) ;
else
printf ("%.2f\n" , bata) ;
}
return ;
}

标程中的大写字母表示角度,小写字母表示边长,注意0的特殊情况即可。

设CE = a = 1,AE = b,AC = c,BE = d,AB = e,AD = f,BD = g,DE = h

使用正弦定理可依次求出AE,AB,AD

然后利用余弦定理依次求出DE,∠AED

其他解法:建立坐标系搞,或者二分搞

上一篇:acdream.Triangles(数学推导)


下一篇:js实现环形菜单效果