XTU 1237 Magic Triangle(几何)

该博客介绍了一道XTU ACM竞赛中的题目,要求根据已知两个角度求解正三角形的第三个角。博主通过应用正弦定理推导出计算公式,并提供了C++代码实现,代码中注意到了sin()函数接受的是弧度而非角度的事实。

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

Magic Triangle

Accepted : 98 Submit : 232
Time Limit : 1000 MS Memory Limit : 65536 KB

Magic Triangle

Problem Description:

Huangriq is a respectful acmer in ACM team of XTU because he brought the best place in regional contest in history of XTU.

Huangriq works in a big company in Guangzhou now, all things goes well but the mosquitos are too disturbing. Mosquito net and mosquito-repellent incense are useless for this mosquito city.

And finally he decides to use magic to kill them. He make a magic regular triangle as the picture shows. While the most proper position to launch magic is not always the center of circle. In order to make everything smoothly, Huangriq needs to get the value of . And he already get two of them, can you help him to figure out the rest one?

Input

The first line contains a integer T(no more than 10000), which indicates the number of test cases. In the following T lines, each line contains two integers a and b () indicating the two angle Huangriq has already got.

Output

For each test case, output the rest angle's value with two digits after a decimal point in one line.

Sample Input

1
30 30

Sample Output

30.00

题意:一个圆里有一个正△ABC 给你其中两个角求第三个角
思路:写出三个小三角形的正弦定理即可求出公式,这里不予推理了。注意库函数里的sin()填的是弧度不是角度
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define pi 3.1415926
int main()
{
    int T;
    double x,y,z;
    double q=pi/180;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%lf %lf",&x,&y);
        z=(sin(x*q)*sin(y*q))/(sin((60.0-x)*q)*sin((60.0-y)*q));
        z+=1.0/2.0;
        z=z*2.0/(sqrt(3.0));
        z=1.0/z;
        z=atan(z);
        z=z*180/pi;
        printf("%.2lf\n",z);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值