UVA - 375 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



题意:
算出全部内切圆(r > 1e-6) 的总和,在计算全部的圆的周长;
公式: 1/2 * b* h = 1/2 * l(三角形的周长)*r (内切圆的半径)


#include<iostream>
#include<math.h>
#include<stdio.h>
#define pi 3.1415926535897932384626

using namespace std;

int main(){
	
	int n;
	cin >> n ;
	while(n --)
	{
		double b;
		double h;
		cin >> b >> h;
		double x = sqrt ( (b/2.0)*(b / 2.0) + h * h);
		double l = x + x + b;
		double r = (1.0 * b * h) / l;

		double R = r;
	double 	sum = r;
		while(1)
		{
			l = l - 2 * b;
			b = b *(h - 2 * R) / h * 1.0;
     		h = h - 2 * R;
			R = (1.0 * b * h) / l ;
			if(R  < 1e-6)
				break;
			sum += R;
			
		
		
		}
	
		printf("%13.6lf\n",sum*2*pi);
		if(n)
			printf("\n");
	}

	return 0;

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值