POJ-2208 Pyramids解题报告

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
题目链接:http://poj.org/problem?id=2208
题目大意:很简单,给你四面体的6个棱长,计算四面体的体积。
题目思路:给大家一个强力的推导公式,1/6*A*B*C*sqrt(1+2cosa*cosb*cosc-cosa^2-cos b^2-cos c^2),其中A,B,C为侧棱长,a,b,c为侧棱之间的夹角,即三个侧面顶角,至于怎么推,我也不知道,嘿嘿,记住就行啦。
实现代码:
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double AB,AC,AD,BC,BD,CD;
	double a,b,c,V;
	while(cin>>AB>>AC>>AD>>BC>>BD>>CD)
	{
		a=(AD*AD+BD*BD-AB*AB)/(2*AD*BD);
		b=(CD*CD+BD*BD-BC*BC)/(2*CD*BD);
		c=(AD*AD+CD*CD-AC*AC)/(2*AD*CD);
		V=1/6.0*AD*BD*CD*sqrt(1+2*a*b*c-a*a-b*b-c*c);
		printf("%.4lf\n",V);
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值