uva 12301 - An Angular Puzzle

题意:如图,已知角ACB, CAE, EAB, CBD, DBA (in degrees), 求 DEA。


注意:在 Output 中,“If there is more than one solution, print "Multiple solutions"”这句话是迷惑你的,根本没有这种情况!

#include<iostream>
#include<iomanip>
#include<cmath>
#define pi (2.0*asin(1.0))

using namespace std;

typedef struct point
{
    double x,y;
    point(double xx=0,double yy=0):x(xx),y(yy){}
}vector;

vector operator - (point a,point b)
{
    return vector(a.x-b.x,a.y-b.y);
}
point operator + (point a,vector b)
{
    return point(a.x+b.x,a.y+b.y);
}
vector operator * (vector a,double b)
{
    return vector(a.x*b,a.y*b);
}
double dot(vector a,vector b)
{
    return a.x*b.x+a.y*b.y;
}
double len(vector a)
{
    return sqrt(dot(a,a));
}
double angle(vector a,vector b)
{
    return acos(dot(a,b)/len(a)/len(b));
}
double cross(vector a,vector b)
{
    return a.x*b.y-a.y*b.x;
}
vector rot(vector a,double rad)
{
    double c=cos(rad),s=sin(rad);
    return vector(a.x*c-a.y*s,a.x*s+a.y*c);
}
point inter(point p,vector v,point q,vector w)
{
    vector u=p-q;
    double t=cross(w,u)/cross(v,w);
    return p+v*t;
}

int main()
{
    double a,b,c,d,e,s;
    point pa,pb,pd,pe;
    pb.x=10;
    while(cin>>a>>b>>c>>d>>e)
    {
        s=a+b+c+d+e;
        if(s==0) break;
        else if(s!=180) cout<<"Impossible"<<endl;
        else
        {
            b*=pi/180;
            c*=pi/180;
            d*=pi/180;
            e*=pi/180;
            vector v=rot(pb-pa,b+c),w=rot(pb-pa,pi-d-e);
            pd=inter(pa,v,pb,rot(pb-pa,pi-e));
            pe=inter(pa,rot(pb-pa,c),pb,w);
            double x=angle(pe-pd,pe-pa)*180/pi;
            cout<<fixed<<setprecision(2)<<x<<endl;
        }
    }
    return 0;
}





  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值