UVA 12301 - An Angular Puzzle(计算几何)

这题就设AB是1,然后正弦余弦定理去搞搞搞就可以了

代码:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const double PI = acos(-1.0);

int a, b, c, d, e;

double get(double x) {
    return x / 180.0 * PI;
}

int main() {
    while (~scanf("%d%d%d%d%d", &a, &b, &c, &d, &e) && a || b || c || d || e) {
        if (a + b + c + d + e != 180) {
            printf("Impossible\n");
            continue;
        }
        double ACB = a, CAE = b, EAB = c, CBD = d, DBA = e;
        double AB = 1.0;
        double AOB = 180 - EAB - DBA;
        double CBA = CBD + DBA;
        double CAB = EAB + CAE;
        double AEB = 180 - EAB - CBA;
        double ADB = 180 - DBA - CAB;
        double BD = AB / sin(get(ADB)) * sin(get(CAB));
        double AE = AB / sin(get(AEB)) * sin(get(CBA));
        double AO = AB / sin(get(AOB)) * sin(get(DBA));
        double BO = AB / sin(get(AOB)) * sin(get(EAB));
        double EO = AE - AO;
        double DO = BD - BO;
        double DE = sqrt(EO * EO + DO * DO - DO * EO * 2 * cos(get(AOB)));
        double x = asin(DO * sin(get(AOB)) / DE) * 180 / PI;
        printf("%.2f\n", x);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值