ACdream 1203 - 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.

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值