Inscribed Circles and Isosceles Triangles

来源:互联网 发布:淘宝点击率多少算正常 编辑:程序博客网 时间:2024/05/29 11:50

Inscribed Circles and Isosceles Triangles

Description

Download as PDF


Given two real numbers

B
the width of the base of an 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 another from the base to the peak; such that the lowest inscribed circle is tangent to the base and the two sides and the next higher inscribed circle is tangent to the lowest inscribed circle and the two sides, etc. In order to keep the time required to compute the result within reasonable bounds, you may limit the radius of the smallest 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 an inscribed circle is at the point of intersection of the three angular bisectors.

Input

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
The input will be a single line of text containing two positive single precision real numbers (BH) separated by spaces.

Output

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
The output should be a single real number with twelve significant digits, six of which follow the decimal point. The decimal point must be printed in column 7.

Sample Input

10.263451 0.263451

Sample Output

     0.827648

大意:

给出一个等腰三角形的底和高,,在这个等腰三角形上不断求内切圆,第一个内切圆与腰和两边相切,第2个内切圆与前一个内切圆和两腰相切;

知道内切圆的半径小与0.000001,求出所有内切圆的周长总和;

要点:

pi = acos(-1.0);

先求腰长d再通过面积法求得r,再由比例法求得每一次的r

#include <cstdio>#include <cmath>int main(){int n;scanf ("%d", &n);double pi = acos(-1.0), d, r, t, sum;while (n--){double b, h;scanf ("%lf%lf", &b, &h);d = sqrt(0.25 * b * b + h * h);r = (b * h) / (2.0 * d + b);t = (h - 2.0 * r) / h;sum = 0.0;while (r >= 0.000001){sum += r;r = r * t;}printf ("%13.6lf\n", sum * 2.0 * pi);if (n)printf ("\n");}return 0;}



0 0