Problem E
In-Circle
Input: Standard Input

Output: Standard Output

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 find the in-circle of a triangle, but will be asked to do the opposite!!

 
You can see in the figure 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 find the area of triangle ABC.

Input

First line of the input file 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 first line contains a floating-point number r (1<r<5000), which denotes the radius of the in-circle. Each of the next three lines contains two floating-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 floating-point number that denotes the area of the triangle ABC. This floating-point number should contain four digits after the decimal point. Errors less than 5*10-3 will be ignored. Use double-precision floating-point number for calculation.

Sample Input                               Output for 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

400156.4075

908824.1322


Problemsetter: Shahriar Manzoor

Special Thanks: Mohammad Mahmudur Rahman


  解析几何

  思路是先设AP=AC=x,则根据比例关系可以知道:

  三边  a = (n1+m1)/m1*x;  b = (n3+m3)/n3*x;  c = m3/n3*(n2+m2)/n2*x;

  将系数提出,设 k1 = (n1+m1)/m1;  k2 = (n3+m3)/n3;  k3 = m3/n3*(n2+m2)/n2;

  由海伦公式可知 S = sqrt(p*(p-a)*(p-b)*(p-c));  (p = (a+b+c)/2)  //公式一

  由边和半径的也能求出三角形的面积 S = (a*r+b*r+c*r)/2 = p*r;      //公式二

  联立公式一和公式二可得:

  x = 2*sqrt(r*r*(k1+k2+k3)/((k2+k3-k1)*(k1+k3-k2)*(k1+k2-k3)));

  带入公式一得:

  S = (k1+k2+k3)*x*r/2;

  PS:代码很短,主要是分析过程。

  代码

 #include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--){
double r;
double m1, n1, m2, n2, m3, n3;
cin>>r; //输入半径
cin>>m1>>n1>>m2>>n2>>m3>>n3; //输入比例
double k1,k2,k3;
k1 = (n1+m1)/m1;
k2 = m3*(n2+m2)/(n3*n2);
k3 = (n3+m3)/n3;
double x = *sqrt(r*r*(k1+k2+k3)/((k2+k3-k1)*(k1+k3-k2)*(k1+k2-k3))); //设AP=AR=x
double s = (k1+k2+k3)*x*r/;
cout<<setiosflags(ios::fixed)<<setprecision();
cout<<s<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

UVa 11524:In-Circle(解析几何)的更多相关文章

  1. UVa 11524 - InCircle

    推公式 #include <cstdio> #include <cmath> double Cal( double a, double b, double c ) { retu ...

  2. uva 11524 - InCircle (二分法)

    题意:三角形ABC的内切圆把它的三边分别划分成 m1:n1,m2:n2 和 m3:n3 的比例.另外已知内切圆的半径 r ,求三角形ABC 的面积. #include<iostream> ...

  3. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

  4. uva 1463 - Largest Empty Circle on a Segment(二分+三分+几何)

    题目链接:uva 1463 - Largest Empty Circle on a Segment 二分半径,对于每一个半径,用三分求出线段到线段的最短距离,依据最短距离能够确定当前R下每条线段在[0 ...

  5. .Uva&LA部分题目代码

    1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...

  6. UVA 1452 八 Jump

    Jump Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practi ...

  7. UVA - 524 Prime Ring Problem(dfs回溯法)

    UVA - 524 Prime Ring Problem Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & % ...

  8. BZOJ 1502: [NOI2005]月下柠檬树 [辛普森积分 解析几何 圆]

    1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1070  Solved: 596[Submit][Status] ...

  9. UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)

    UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...

随机推荐

  1. 从HashMap透析哈希表

    ##扯数据结构 先看一下哈希表的概念: 哈希表是一种数据结构,它可以提供快速的插入操作和查找操作.第一次接触哈希表,他会让人难以置信,因为它的插入和删除.查找都接近O(1)的时间级别.用哈希表,很多操 ...

  2. Java-java中的有符号,无符号操作以及DataInputStream

    1. 无符号和有符号 计算机中用补码表示负数,并且有一定的计算方式:另外,用二进制的最高位表示符号,0表示正数.1表示负数.这种说法本身没错,可是要有一定的解释,不然它就是错的,至少不能解释,为什么字 ...

  3. 回家前的挣扎——SQLite增删改查

    引言 最后一天,公司就两个人,也不知道弄点什么,就在网上找了Sqlite的文档,看了看,这里也是现学现卖,给自己找点事做,感觉时间过得还是比较快的,不然焦急等待,滋味不好受啊. SQLite简介 SQ ...

  4. wes开发笔记

    html中的button和submit有什么不同? submit是提交表单用,而button是执行javascript用,两者各有用处. 用到自己写按钮的时候,都是用button,submit很少写 ...

  5. ubuntu系统 用户进入后命令行只有一个“$” 美元符号

    在新添加用户后,切换到该用户下面后: 发现命令行前面只有一个$符号,很不方便. 虽然每次输入一个bash可以解决,但是太麻烦. 如何解决呢? sudo vi /etc/passwd 找到该用户 wan ...

  6. 物理学家的LOGO

    原文选自Inside the Perimeter 阿那克西曼德(c. 610-546 BCE) 古希腊人,被认为是史上第一位物理学家,是有记录的认为世界按一定规律运行的第一人,做科学实验第一人,发明了 ...

  7. HDOJ 1524 A Chess Game

    A Chess Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  8. 怎么让dedecms生成html页面更快些

    如何让织梦生成html页面更快些呢? 1.把文章模板里的“相关文章”.“热点文章”.“推荐文章”这类的标记删除了,用其它方式,如:shtml.js 引入 2.把织梦模板里用标记表示的模板路径.php附 ...

  9. 用WP_Query自定义WordPress 主循环

    我们知道操作 WordPress 主循环(WordPress Loop)最容易的方法是使用 query_posts 函数. 但是使用 query_posts 直接修改 WordPress 默认的主循环 ...

  10. 【ERROR】使用jquery的ajax出现error:readyState=4,status=500

    使用jquery的ajax出现error:readyState=4,status=500,ajax代码如下: $.ajax({ url : "../toBeFinMisManage/show ...