由角a、b、c、d、e可以确定三角形ABC的形状,所以不妨以A为原点,AB为x轴建立直角坐标系。然后求出D、E的坐标,然后在三角形ADE中运用余弦定理就可以求出结果了。
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const double eps=1e-8;
int dcmp(double x)
{
if(fabs(x)<eps) return 0;
else return x<0?-1:1;
}
struct point
{
double x,y;
point(double x=0,double y=0):x(x),y(y){}
};
point operator-(point a,point b){return point(a.x-b.x,a.y-b.y);}
point operator+(point a,point b){return point(a.x+b.x,a.y+b.y);}
point operator*(point a,double p){return point(a.x*p,a.y*p);}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
double length(point a){return sqrt(a.x*a.x+a.y*a.y);}
point rot(point a,double rad){return point(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));}
double torad(double deg)
{
return deg/180*acos(-1.0);
}
point getinter(point p,point v,point q,point w)
{
point u=p-q;
double t=cross(w,u)/cross(v,w);
return p+v*t;
}
int main()
{
freopen("in.txt","r",stdin);
int a,b,c,d,e;
while(cin>>a>>b>>c>>d>>e)
{
if(!a&&!b&&!c&&!d&&!e) break;
if(a+b+c+d+e!=180||a<=0||b<=0||c<=0||d<=0||e<=0)
{
cout<<"Impossible"<<endl;
continue;
}
point A=point(0,0),B=point(1,0);
point ac=rot(B-A,torad(b+c));
point bc=rot(B-A,torad(180-d-e));
point ae=rot(B-A,torad(c));
point bd=rot(B-A,torad(180-e));
point D=getinter(B,bd,A,ac);
point E=getinter(A,ae,B,bc);
double l1=length(D-E),l2=length(A-E),l3=length(A-D);
double ans=acos((l1*l1+l2*l2-l3*l3)/(2*l1*l2));
printf("%.2f\n",ans/acos(-1.0)*180);
}
return 0;
}