Inscribed Circles and Isosceles Triangles |
Given two real numbers
Compute to six significant decimal places
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.
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.
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.
1 0.263451 0.263451
0.827648
题目大意:
给你一个等腰三角形的底和高,叫你算出等腰三角形的所有的内切圆的周长的和,精确到小数点后6位。
注意:为了保证PI的精确,PI = arccos(-1)
#include <stdio.h> #include <math.h> const double PI = acos(-1.0); int main() { int t; while(scanf("%d",&t) != EOF) { while(t--) { double b,h; double a,r,sum; sum=a=r=0; scanf("%lf%lf",&b,&h); while(1) { a = atan(h/(b/2)); r = ( b*tan(a/2) )/2; if(r < 1e-6) break; sum += 2*PI*r; b = b*(h - 2*r)/h; h = h - 2*r; } printf("%13.6lf\n",sum); if(t != 0) printf("\n"); } } return 0; }