前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >POJ 2208--Pyramids(欧拉四面体体积计算)

POJ 2208--Pyramids(欧拉四面体体积计算)

作者头像
Enterprise_
发布2019-02-20 10:40:48
4460
发布2019-02-20 10:40:48
举报
文章被收录于专栏:小L的魔法馆小L的魔法馆

Pyramids

Time Limit: 1000MS Memory Limit: 65536K

Total Submissions: 3448 Accepted: 1122 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

利用欧拉四面体计算公式带入计算

HDU 1411一样,只是是否是多组输入的问题。

/*
*Memory: 188K       Time: 47MS
*Language: C++      Result: Accepted
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
//p,q,r为AD,BD,CD;n,l,m为AB,BC,AC;
double V_tetrahedron(double l, double m, double n, double q, double p, double r) {
    //return sqrt((4 * p*p*q*q*r*r - p*p*(q*q + r*r - l*l)*(q*q + r*r - l*l) - q*q*(r*r + p*p - m*m)*(r*r + p*p - m*m) - r*r*(p*p + q*q - n*n)*(p*p + q*q - n*n) + (p*p + q*q - n*n)*(q*q + r*r - l*l)*(r*r + p*p - m*m))) / 12.0;
    double x = q*q + r*r - l*l, y = r*r + p*p - m*m, z = p*p + q*q - n*n;
    return sqrt((4 * p*p*q*q*r*r - p*p*x*x - q*q*y*y - r*r*z*z + z*x*y)) / 12.0;
}
int main(){
    double l,m,n,q,p,r;
    cin>>n>>m>>p>>l>>q>>r;
    double ans=V_tetrahedron(l,m,n,q,p,r);
    printf("%.4lf\n",ans);
    return 0;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年08月22日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档