题目:375 - Inscribed Circles and Isosceles Triangles
题目大意:求一个等腰三角形里的内切圆的周长和。内切圆半径精确到0.000001就可以了。
解题思路:关键求出内切圆的半径。还有π在计算机中的表示方法acos(-1).其余的可以看看上传的图片(图片是别人那里拿来的),上面解释的很清晰。
#include<stdio.h>
#include<math.h>
int t;
double b, h;
double A, r, sum;
int main() {
scanf("%d", &t);
while( t-- ) {
scanf("%lf%lf", &b, &h);
sum = 0;
while(1) {
A = atan(2 * h / b);
r = 0.5 * tan(A / 2) * b;
if(r < 1e-6)
break;
sum += acos(-1) * 2 * r;
b = (h - 2 * r) * b / h;
h = h - 2 * r;
}
printf("%13.6lf\n", sum);
if(t)
printf("\n");
}
return 0;
}