最省納智捷1年新車83萬起5檔高息股比定存強10倍這畫面也太叫人垂涎欲滴!睽違25天終開會 立院...
2012-04-20 16:28:02 人氣(186) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA][Math] 10347 - Medians

0
收藏
0
推薦

Problem C
Medians

Input: standard input
Output: standard output
Time Limit: 1 second
Memory Limit: 32 MB

Given the length of three medians of a triangle you will have to find out the area of the triangle. Unless you are weak in geometry you should know that median of a triangle is formed by connecting any vertex of a triangle and the mid-point of its opposite edge. So a triangle has three medians.

Input

The input file contains 1000 lines of input. Each line contains three numbers which denote the length of the medians of a triangle. All the values in the input will be less than 100. Input is terminated by end of file.

Output

For each line of input you should produce one line of output. This line should contain the area of the triangle for the corresponding input. If it is not possible to form a triangle with the given medians, the area of the triangle should be set as -1. The areas should be rounded up to three digits after the decimal point.

Sample Input

3 3 3

3 3 3 

Sample Output

5.196

5.196



三中線交點是重心,用海龍公式求面積


#include <stdio.h>
#include <math.h>

int main() {
    double a, b, c;
    while(scanf("%lf %lf %lf", &a, &b, &c) == 3) {
        if(a+b <= c || b+c <= a || c+a <= b) {
            puts("-1.000");
            continue;
        }
        a = a*(2/3.0);
        b = b*(2/3.0);
        c = c*(2/3.0);
        double s = (a+b+c)/2.0;
        printf("%.3lf\n", 3*sqrt(s*(s-a)*(s-b)*(s-c)));
    }
    return 0;
}
 

 

10347Medians
台長:Morris
人氣(186) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][DFS] 989 - Su Doku
此分類上一篇:[UVA][DP] 1213 - Sum of Different Primes

我要回應
是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入以下數字 (ex:123)

(有*為必填)
詳全文