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

Pyramids
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3451   Accepted: 1123   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

 

Problem: 2208    
Memory: 188K   Time: 47MS
Language: C++   Result: Accepted
复制代码
 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cmath>
 4 #include<cstdio>
 5 using namespace std;
 6 //p,q,r为AD,BD,CD;n,l,m为AB,BC,AC;
 7 double V_tetrahedron(double l, double m, double n, double q, double p, double r) {
 8     //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;
 9     double x = q*q + r*r - l*l, y = r*r + p*p - m*m, z = p*p + q*q - n*n;
10     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;
11 }
12 int main(){
13     double l,m,n,q,p,r;
14     cin>>n>>m>>p>>l>>q>>r;
15     double ans=V_tetrahedron(l,m,n,q,p,r);
16     printf("%.4lf\n",ans);
17     return 0;
18 }
View Code
复制代码

 

posted @   Chasssser  阅读(405)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示