题意:三角形ABC的内切圆把它的三边分别划分成 m1:n1,m2:n2 和 m3:n3 的比例。另外已知内切圆的半径 r ,求三角形ABC 的面积。
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#define sqr(a) (a)*(a)
#define eps 1e-12
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
#define pi asin(1.0) using namespace std; int sig(double a)
{
return (a>eps)-(a<-eps);
} int main()
{
int t;
double r,m1,n1,m2,n2,m3,n3,k1,k2,k3;
double left,right,mid,thy,th1,th2,th3;
cin>>t;
while(t--)
{
cin>>r>>m1>>n1>>m2>>n2>>m3>>n3;
k1=sqr(n1);
k2=sqr(n2/m2)*k1;
k3=sqr(m1);
left=min(sqrt(3/k1)*r,sqrt(3/k2)*r);
left=min(left,sqrt(3/k3)*r);
right=max(sqrt(3/k1)*r,sqrt(3/k2)*r);
right=max(right,sqrt(3/k3)*r);
mid=(left+right)/2;
while(sig(right-left)>0)
{
th1=r/sqrt(k1*sqr(mid)+sqr(r));
th2=r/sqrt(k2*sqr(mid)+sqr(r));
th3=r/sqrt(k3*sqr(mid)+sqr(r));
thy=asin(th1)+asin(th2)+asin(th3);
int f=sig(thy-pi);
if(f==0) break;
else if(f<0) right=mid;
else left=mid;
mid=(left+right)/2;
}
thy=2*asin(r/sqrt(k1*sqr(mid)+sqr(r)));
double area=(n1+m1)*mid/2*(n2+m2)*n1/m2*mid*sin(thy);
cout<<fixed<<setprecision(4)<<area<<endl;
}
return 0;
}