UVA375 Inscribed Circles and Isosceles Triangles

2023-10-14 09:30

本文主要是介绍UVA375 Inscribed Circles and Isosceles Triangles,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

思路:简单几何题....


#include <cstdio>
#include <cmath>
using namespace std;
const double pi = atan(1.0) * 4;double b, h, l, th, r, k;int main() {int n;scanf("%d", &n);while (n--) {scanf("%lf%lf", &b, &h);l = sqrt(b * b / 4 + h * h);r = b * h / (b + 2 * l);th = 2 * r;k = r / h;l = h - r * 2;while (l * k > 0.000001) {l -= l * k * 2;}printf("%13.6lf\n", pi * (h - l));if (n)printf("\n");}return 0;
}


Description

Download as PDF


 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

10.263451 0.263451

Sample Output

     0.827648


这篇关于UVA375 Inscribed Circles and Isosceles Triangles的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/209649

相关文章

Social Circles

来自codeforces You invited nn guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circl

Right Triangles

H - Right Triangles Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit  Status  Practice  CodeForces 52B Description You are given a n × m field consistin

--uva247(calling circles)强联通与floyd-warshell

图论题:一开始我是用tarjan算法做的,wrong answer 了很多次,然后又用了floyd-warshell算法,也wa了 最后找了题解,原来最后的dataset后面不是组数,是样例的编号,题根本就没说,让人怎么理解。。。 tarjan #include<stdio.h>#include<iostream>#include<string.h>#include<string>#

hdu 5135 Little Zu Chongzhi's Triangles(计算几何:三角形面积)

给出多条木棍,问你用这些木棍所能组成的多个三角形面积最大和是多少 贪心做,所以先排序,但是遍历的过程中不能从前向后遍历 因为可能会存在4条边取后三条边是最优的类似情况 正解是从后向前遍历,用海伦公式求解 代码如下: /* ***********************************************Author :yinhuaEmail

lightoj 1307 Counting Triangles | 二分/暴力

题意: 给你N条边,问你能组成三角形的方法数。 思路: 判断三条边能否组成三角形,根据任意两条边的和大于第三边。 实际上,在确定A<=B<=C的情况下,只要A+B的和大于C即可认为ABC能组成三角形。 这题可以不用二分,用二分速度反而变慢了。排好序后乱搞就可以了。 AC代码: #include <cstring>#include <cstdlib>#include <cstd

Qt5官方demo解析集34——Concentric Circles Example

本系列所有文章可以在这里查看http://blog.csdn.net/cloud_castle/article/category/2123873 接上文Qt5官方demo解析集33——Qt Quick Examples - Window and Screen 好像有一段时间没有更新这个系列了,一方面是很多的事掺杂着一起来了,稍微比原来忙了一些;但时间哪有挤不出来的呢,所以更重要的一个原因其

UVA - 585 Triangles

题意:求最大的三角形 思路:先初始化从左到右和从右到左的最大连续的‘-’,然后就是当奇数列的时候找头向下的三角形,偶数的时候相反找 #include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 200;char map[

UVA 12508 - Triangles in the Grid(计数问题)

12508 - Triangles in the Grid 题目链接 题意:给定一个n∗m格子的矩阵,然后给定A,B,问能找到几个面积在A到B之间的三角形。 思路:枚举每一个子矩阵,然后求[0,A]的个数减去[0,B]的个数就是答案,然后对于每个子矩阵个数很好求为(n−r+1)∗(m−c+1)。关键在于怎么求每个子矩阵的符合个数。 想了好久,参考别人题解才想出来,分3种情况讨论:

Uva375

等腰三角形的内切圆,再在内切圆的基础上做内切圆,此内切圆圆前一个内切圆相切,以此类推,直到内切圆的半径达到所要的精度! #include<stdio.h> #include<math.h> const double pi=4.0*atan(1.0); int main() {     double H,B,a,b,r,n;     scanf("%lf\n",&n);     while(n--

深度优先搜索 | 547. Friend Circles

一、题目 给定一个二维的 0-1 矩阵,如果第 (i, j) 位置是 1,则表示第 i 个人和第 j 个人是朋友。已知朋友关系是可以传递的,即如果 a 是 b 的朋友,b 是 c 的朋友,那么 a 和 c 也是朋友,换言之这三个人处于同一个朋友圈之内。求一共有多少个朋友圈。 输入输出样例输入是一个二维数组,输出是一个整数,表示朋友圈数量。因为朋友关系具有对称性,该二维数组为对称矩阵。同时,因为