首页 > 其他 > 详细

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

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

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(解题报告)

原文:http://blog.csdn.net/luwhere/article/details/47687013

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!