zoukankan      html  css  js  c++  java
  • 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就是这么奇怪。。

     
  • 相关阅读:
    ECC 构筑安全可靠的区块链
    代理模式和装饰者模式
    Context都没弄明白,还怎么做Android开发?
    如何在Android Studio中查看一个类的继承关系呢?
    Android控件的继承关系
    安卓控件体系结构
    Android View框架总结(三)View工作原理
    Laravel中用GuzzleHttp
    学习PHP好,还是Python好呢?
    ElasticSearch入门 第一篇:Windows下安装ElasticSearch
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2446378.html
Copyright © 2011-2022 走看看