题目大意
给定L,n,C,L为红色线段,L(1+n*C)为绿色弧,求两者中点的距离
二分圆心角度数,接下来就是几何的能力了
根据正弦定理,可得:
则弧长:
将a与nL作比较来二分
精度满天飞 QWQ
代码如下:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
double pi=3.1415926535897932384626433832795,eps=0.000000001;
double L,C,n,nL;
using namespace std;
double work(double mid)
{
double a1=sin(2*pi*mid/360),a2=sin(2*pi*(90-mid/2)/360);
double r=L/a1*a2;
return 2*r*pi*mid/360;
}
int main()
{
while(scanf("%lf%lf%lf",&L,&n,&C))
{
if(L==-1&&n==-1&&C==-1)return 0;
nL=(1+n*C)*L;
if(nL==L){printf("0.000
");continue;}
double l=0,r=180,mid;
while(r-l>eps)
{
mid=(l+r)/2;
if(work(mid)<nL)l=mid;
else r=mid;
}
printf("%.3lf
",L/sin(2*pi*l/360)*sin(2*pi*(90-mid/2)/360)-sqrt(pow(L/sin(2*pi*l/360)*sin(2*pi*(90-mid/2)/360),2)-pow(L/2,2)));
}
}