码迷,mamicode.com
首页 > 其他好文 > 详细

ACdream 1203 - KIDx's Triangle(解题报告)

时间:2015-08-15 23:05:58      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:math

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.

技术分享

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!