数学 ACdream 1196 KIDx's Triangle

 

题目传送门

 1 /*  2  这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧!  3  注意:a==0时要特判:)  4 */  5 #include <cstdio>  6 #include <algorithm>  7 #include <iostream>  8 #include <cstring>  9 #include <string> 10 #include <cmath> 11 using namespace std; 12 13 const int MAXN = 1e4 + 10; 14 const int INF = 0x3f3f3f3f; 15 const double PI = acos (-1.0); 16 17 double f(double k) 18 { 19 return 1.0 * k * PI / 180; 20 } 21 22 int main(void) //ACdream 1196 KIDx's Triangle 23 { 24 //freopen ("H.in", "r", stdin); 25 26 double a, b, c, d; 27 double ae, cd, ce, de, ab, ad, be, bd; 28 double x; 29 while (scanf ("%lf%lf%lf%lf", &a, &b, &c, &d) == 4) 30  { 31 if (a == 0) 32  { 33 puts ("0.00"); continue; 34  } 35 36 ad = sin (f(c)) / sin (f(a+b+c)); 37 ae = sin (f(c+d)) / sin (f(b+c+d)); 38 be = sin (f(b)) / sin (f(b+c+d)); 39 bd = sin (f(a+b)) / sin (f(a+b+c)); 40 de = sqrt (be*be + bd*bd - 2 * be * bd * cos (f(d))); 41 42 x = acos ((de*de+ae*ae-ad*ad) / (2.0 * de * ae)) * 180 / PI; 43 44 if (x < 0) printf ("%.2f\n", 180.0 - x); 45 else printf ("%.2f\n", x); 46  } 47 48 return 0; 49 }

 

你可能感兴趣的:(KIDx)