UVa 375 inscribed Circles and isosceles triangles (isosceles incircle & Law)
375-inscribed Circles and isosceles triangles
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=101&page=show_ problem&problem=311
Given Two real numbers
B
The width of the base of the isosceles triangle in inches
H
The altitude of the same isosceles triangle in inches
Compute to six significant decimal places
C
The sum of the circumferences of a series of inscribed circles stacked one on top of the another from the base to the peak; such that the lowest inscribed circle are tangent to the base and the two sides and the next higher inscribed-Is TAN Gent to the lowest inscribed circle and the two sides, etc. In order to keep the "required to compute" result within reasonable bounds, your may limit the radius of the Smalles T inscribed circle in the stack to a single precision floating point value of 0.000001.
For those whose geometry and trigonometry are a bit rusty, the center of a inscribed circle are at the point of intersecti On the three angular bisectors.
Input
The input begins with a single positive integer in a line by itself indicating the number of cases following, each of them as described below. This are followed by a blank line, and there are also a blank line between two consecutive.
The input would be a single line of text containing two positive single precision real numbers (B H) separated by spaces.
Output
For each test case, the output must follow the description below. The outputs of two consecutive cases is separated by a blank line.
The output should is a single real number with twelve significant digits, six of which follow the decimal point. The decimal point must is printed in column 7.
Sample Input
1
0.263451 0.263451
Sample Output
0.827648
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
1. How to find the incircle radius? -Through the heart to three edge to do perpendicular, and then link heart with three vertices, by the area equal to 0.5* (a+b+c) *r = Triangle Area S, that is, r=2*s/(a+b+c)
2. What is the radius of the next circle? The high H and B in the formula are replaced with H-2R and b* (H-2R)/h--and then the sequence R is found to be a sequence of ratios. (But O (1) of the formula method to achieve the problem of precision is not allowed to do)
Complete code:
/*0.069s*/
#include <cstdio>
#include <cmath>
const DOUBLE PI = 2 * acos (0);
int main ()
{
int n;
Double B, H, R, K, R;
scanf ("%d", &n);
while (n--)
{
scanf ("%lf%lf", &b, &h);
R = b * H/(b + sqrt (b * b + 4 * H * h));
K = 1-2 * r/h;
R = 0;
while (R >= 1e-6)
{
r = r;
R *= K;
}
printf ("%13.6f\n", pi * R * 2);///Note is the
if (n) putchar (a);
return 0;
}