POJ 2208 Pyramids(欧拉四面体公式)

Pyramids
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2268   Accepted: 751   Special Judge

Description

Recently in Farland, a country in Asia, a famous scientist Mr. Log Archeo has discovered ancient pyramids. But unlike those in Egypt and Central America, they have triangular (not rectangular) foundation. That is, they are tetrahedrons in mathematical sense. In order to find out some important facts about the early society of the country (it is widely believed that the pyramid sizes are in tight connection with Farland ancient calendar), Mr. Archeo needs to know the volume of the pyramids. Unluckily, he has reliable data about their edge lengths only. Please, help him!

Input

The file contains six positive integer numbers not exceeding 1000 separated by spaces, each number is one of the edge lengths of the pyramid ABCD. The order of the edges is the following: AB, AC, AD, BC, BD, CD.

Output

A real number -- the volume printed accurate to four digits after decimal point.

Sample Input

1000 1000 1000 3 4 5

Sample Output

1999.9938

Source

Northeastern Europe 2002, Northern Subregion
 

关于欧拉四面体公式的推导及证明过程

2010-08-16 14:18

1,建议x,y,z直角坐标系。设A、B、C少拿点的坐标分别为(a1,b1,c1),(a2,b2,c2),(a3,b3,c3),四面体O-ABC的六条棱长分别为l,m,n,p,q,r;

2,四面体的体积为,由于现在不知道向量怎么打出来,我就插张图片了,




将这个式子平方后得到:

3,根据矢量数量积的坐标表达式及数量积的定义得



又根据余弦定理得

4,将上述的式子带入(1),就得到了传说中的欧拉四面体公式




 代码:

#include<stdio.h>

#include<math.h>

int main()

{

    double p,q,r,n,m,l;

    while(scanf("%lf%lf%lf%lf%lf%lf",&p,&q,&r,&n,&m,&l)!=EOF)

    {

        double tmp1=(p*p+q*q-n*n)/2;

        double tmp2=(p*p+r*r-m*m)/2;

        double tmp3=(q*q+r*r-l*l)/2;

        

        double M1=q*q*r*r-tmp3*tmp3;

        double M2=r*r*tmp1-tmp2*tmp3;

        double M3=tmp1*tmp3-q*q*tmp2;

        

        double V=sqrt(p*p*M1-tmp1*M2+tmp2*M3);

        V/=6.0;

        printf("%.4lf\n",V);

    }    

    return 0;

}    

要C++才能过

G++会WR的

POJ就是这么奇怪。。

 

你可能感兴趣的:(poj)