An Angular Puzzle - UVa 12301 几何

本文介绍了一道经典的几何角度求解谜题,并提供了一个通过编程解决该问题的方法。利用正弦定律和余弦定律,结合输入参数计算指定角度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

An Angular Puzzle

Here is an old interesting puzzle: In the picture below, what is the angle of DEA, in degrees? Note that 5 angles are already given. The picture is drawn to scale.

You're to solve a generalized problem: let a, b, c, d, e be the angle of ACB, CAE, EAB, CBD, DBA (in degrees), what is the angle of DEA, in degrees?

Note that E must be strictly on segment BC (cannot coincide with B or C), and D must be strictly on segment AC (cannot coincide with A or C). The triangle ABC must be non-degenerated (i.e. ABC cannot be collinear). Not all combination of parameters a, b, c, d and e corresponds to a valid figure described above. Your program should be able to detect this.

Input

There will be at most 100 test cases. Each case contains 5 integers a, b, c, d, e (0 < a, b, c, d, e < 90). The last test case is followed by five zeros, which should not be processed.

Output

For each test case, print the answer to two decimal places. If there is more than one solution, print "Multiple solutions". If the input is incorrect (i.e. there is no valid picture for these parameters), print "Impossible" (without quotes).

Sample Input

20 10 70 20 60
30 5 70 15 60
60 30 30 30 30
30 40 40 40 40
0 0 0 0 0

Output for the Sample Input

20.00
12.96
30.00
Impossible

题意:求图中角x的大小。

思路:假设AB=1,那么可以求出AD,AE的长度,进而可以求出DE的长度,然后x的大小就可以求出。

AC代码如下:

#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    double AB,AE,AD,p,DE,ans;
    while(~scanf("%d%d%d%d%d",&a,&b,&c,&d,&e) && a+b+c+d+e>0)
    {
        if(a+b+c+d+e!=180)
        {
            printf("Impossible\n");
            continue;
        }
        AB=1;
        AE=AB*sin((d+e)*M_PI/180)/sin((180-c-d-e)*M_PI/180);
        AD=AB*sin(e*M_PI/180)/sin((180-b-c-e)*M_PI/180);
        DE=sqrt(AE*AE+AD*AD-2*AE*AD*cos(b*M_PI/180));
        ans=acos((AE*AE+DE*DE-AD*AD)/(2*AE*DE))/M_PI*180;
        printf("%.2f\n",ans);
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值