375 - Inscribed Circles and Isosceles Triangles

题目: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;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值