题目
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5476
题目来源:2015上海网络赛第四题
简要题意:算三角形内两个角相等的轨迹长度,具体看题目吧。
数据范围: 1⩽T⩽104;|xi|,|yi|⩽104
题解
∠BDC=180∘−∠BAC结果为 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;
}