Inscribed Circles and Isosceles Triangles
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
1 0.263451 0.263451
Sample Output
0.827648题意:在等腰三角形里画内切圆,当最小的那个圆的半径小于0.000001时,求出所有圆的周长和(注意:π=3.1415926不行,要继续写出后面的数,可以直接用π=arcsin(1)*2)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define pi asin(1)*2
int main()
{
int n,t=0;
double B,H,r,sum,ans;
scanf("%d",&n);
while(n--)
{
scanf("%lf%lf",&B,&H);
r=1;sum=0;
while(1)
{
r=tan(atan(2*H/B)/2.0)*B/2;
if(r<0.000001)
break;
sum+=r;
B=(H-2*r)*B/H;
H=H-2*r;
}
if(t)
{
printf("\n");
}
t++;
ans=2*pi*sum;
printf("%13.6lf\n",ans);
}
return 0;
}

本文介绍了一种计算等腰三角形中一系列内切圆周长总和的方法,通过递减的内切圆半径直至达到指定精度(0.000001),使用C语言实现并考虑了数学中的π值精确表示。
1506

被折叠的 条评论
为什么被折叠?



