UVA_11524_InCircle

11524 - InCircle

Time limit: 2.000 seconds


In-circle of a triangle is the circle that touches all the three sides of the triangle internally. The center
of the in-circle of a triangle happens to be the common intersection point of the three bisectors of the
internal angles. In this problem you will not be asked to nd the in-circle of a triangle, but will be
asked to do the opposite!!
You can see in the gure above that the in-circle of triangle ABC touches the sides AB, BC and
CA at point P, Q and R respectively and P, Q and R divides AB, BC and CA in ratio m1:n1, m2:n2
and m3:n3 respectively. Given these ratios and the value of the radius of in-circle, you have to nd the
area of triangle ABC.
Input
First line of the input le contains an integer N (0 < N < 50001), which denotes how many input sets
are to follow. The description of each set is given below.
Each set consists of four lines. The rst line contains a 
oating-point number r (1 < r < 5000),
which denotes the radius of the in-circle. Each of the next three lines contains two 
oating-point
numbers, which denote the values of m1, n1, m2, n2, m3 and n3 (1 < m1; n1;m2; n2;m3; n3 < 50000)
respectively.
Output
For each set of input produce one line of output. This line contains a 
oating-point number that
denotes the area of the triangle ABC. This 
oating-point number should contain four digits after the
decimal point. Errors less than 5 *10^-3 will be ignored. Use double-precision 
oating-point number
for calculation.
Sample Input
2
140.9500536497
15.3010457320 550.3704847907
464.9681681852 65.9737378230
55.0132446384 10.7791711946
208.2835101182
145.7725891419 8.8264176452
7.6610997600 436.1911036207
483.6031801012 140.2797089713
Sample Output
400156.4075
908824.1322


这个题目就是告诉一个三角形内切圆的半径

以及各边切点两边部分的比值

要求求三角形的面积

三角形的面积可以用多种方法求

这个题目恰恰可以用面积作为桥梁

三角形三边长 a,b,c

于是S=r(a+b+c)/2

又可以通过海伦公式

S=sqrt(p(p-a)(p-b)(p-c))

其中p=(a+b+c)/2即半周长


此时我们并不知道具体的边长 但是

我们设a的长度是k 然后其他的两边都可以用k和比例来表示

如果我们认为a的长度是1

那么我们用海伦公式算出的面积是实际面积的1/k^2

而用内切圆半径算出的面积是实际面积的1/k

因此通过这两个结果可以求出k的值

进而将k带回可以求出面积


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

const double PI=acos(-1.0);

int main()
{
    int t;
    scanf("%d",&t);
    double r,n1,m1,n2,m2,n3,m3;
    while(t--)
    {
        scanf("%lf",&r);
        scanf("%lf%lf%lf%lf%lf%lf",&m1,&n1,&m2,&n2,&m3,&n3);//这里特别注意变量的输入顺序
        double a=1.0;
        double b=(n1+n1/m2*n2)/(n1+m1);
        double c=(m1+m1/n3*m3)/(n1+m1);
        //cout<<b<<" "<<c<<endl;
        double p=(a+b+c)/2.0;         //周长的一半
        double s=sqrt(p*(p-a)*(p-b)*(p-c));  //海伦公式
        double ss=r*p;
        //cout<<ss<<" "<<s<<" "<<ss/s<<" "<<ss/s/(n1+m1)<<endl;
        printf("%.4lf\n",ss*ss/s);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值