UVA10195 The Knights Of The Round Table【计算几何】

King Arthur is planning to build the round table in a new room, but this time he wants a room that have sunlight entering it, so he planned to build a glass roof. He also wishes his round table to shine during the day, specially at noon, so he wants it to be covered totally by the sunlight. But Lancelot wants the glass part of the room roof to be triangular (and nobody knows the reason why, maybe he made a vow or something like that). So, there will be a triangular area in the room which will be all covered by the sunlight at noon and the round table must be build in this area.
    Now, King Arthur wants to build the biggest table that he cans such that it fits in the triangular sunlighted area. As he is not very good in geometry, he asked Galahad to help him (Lancelot is very good in geometry, but King Arthur didn’t asked Lancelot to help him because he feared that he would come up with another strange suggestion).
    Can you help Galahad (since he’s not too good with computers) and write a program which gives the radius of the biggest round table that fits in the sunlighted area? You can assume that the round table is a perfect circle.
Input
There’ll be an arbitrary number of rooms. Each room is represented by three real numbers (a, b and c), which stand for the sizes of the triangular sunlighted area. No triangle size will be greater than 1000000 and you may assume that max(a, b, c) ≤ (a + b + c)/2.
    You must read until you reach the end of the file.
Output
For each room configuration read, you must print the following line:
The radius of the round table is: r
    Where r is the radius of the biggest round table that fits in the sunlighted area, rounded to 3 decimal digits.
Sample Input
12.0 12.0 8.0
Sample Output
The radius of the round table is: 2.828

问题链接UVA10195 The Knights Of The Round Table
问题简述:给定三角形三边长,计算内切圆半径。
问题分析:计算几何题,看程序代码。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10195 The Knights Of The Round Table */

#include <bits/stdc++.h>

using namespace std;

int main()
{
    double a, b, c;
    while(scanf("%lf %lf %lf", &a, &b, &c) != EOF) {
        if(0==a || 0==b || 0==c) {
            printf("The radius of the round table is: 0.000\n");
            continue;
        }
        printf("The radius of the round table is: %.3f\n",
               a * b * sin(acos((a * a + b * b - c * c) / (2.0 * a * b))) / (a + b + c));
    }

    return 0;
}
原创文章 2323 获赞 2382 访问量 269万+

猜你喜欢

转载自blog.csdn.net/tigerisland45/article/details/105781641