hdu 5476 Explore Track of Point 2015上海网络赛 几何

题目

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5476

题目来源:2015上海网络赛第四题

简要题意:算三角形内两个角相等的轨迹长度,具体看题目吧。

数据范围: 1T104;|xi|,|yi|104

题解

这里写图片描述
BDC=180BAC

结果为 AM+BPC

基本上是画图然后猜测的结论的。

这次网络赛几道题好像我们都是连蒙带猜乱搞出来的。

实现

知道结论之后其实使用三角公式很好推出结果,要注意的是求角度要用acos,因为asin不好处理大于 45 的角。

代码

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
LL powmod(LL a,LL b, LL MOD) {LL res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// head
const double PI = acos(-1.0);

double sq(double x) {
    return x*x;
}
double dis(PDD &a, PDD &b) {
    return sqrt(sq(a.fi-b.fi)+sq(a.se-b.se));
}
int main()
{
    int t, cas = 1;
    scanf("%d", &t);
    PDD a, b, c;
    while (t--) {
        scanf("%lf%lf%lf%lf%lf%lf", &a.fi, &a.se, &b.fi, &b.se, &c.fi, &c.se);
        double BC = dis(b, c), AC = dis(a, c);
        double BM = BC/2, AM = sqrt(sq(AC)-sq(BM));
        double A = acos(AM/AC)*2;
        double D = PI-A;
        double h = sqrt(sq(AC)-sq(BM));
        double R = BM/sin(D/2);
        printf("Case #%d: %.4f\n", cas++, h+R*D);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值