UVA 375 (暑假-几何 -B - Inscribed Circles and Isosceles Triangles)

#include <cstdio>
#include <cmath>

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		double base, height;
		scanf("%lf%lf", &base, &height);
		double len = sqrt(base * base / 4 + height * height);
		double r = (base * height) / (len * 2 + base);   
		double rate =  r / height; 
		double h = height - 2 * r;

		while (h * rate > 1e-6) {
			h -= 2 * h * rate;
		} 

		printf("%13.6lf\n", (height - h) * 4 * atan(1));
		if (t)
			printf("\n");
	}
	return 0;
}

你可能感兴趣的:(UVA 375 (暑假-几何 -B - Inscribed Circles and Isosceles Triangles))