您的位置:首页 > Web前端 > AngularJS

An Angular Puzzle - UVa 12301 几何

2015-02-05 16:08 441 查看

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);
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: