POJ 2208 Pyramids && HDU 1141 校庆神秘建筑 (欧拉四面体公式)

29 篇文章 0 订阅
20 篇文章 0 订阅
Pyramids
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 2951 Accepted: 973 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
一个公式,可以去看下证明。。。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#define inf 0x3f3f3f3f
#define N 1001
using namespace std;
int main()
{
    __int64 a, b, c, d, e, f;                //用double 和int 都会WA  快WA哭了
    while(~scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &a, &b, &c, &d, &e, &f))
    {
        double v = sqrt
                    (
                    4*a*a*b*b*c*c
                  - a*a * (b*b + c*c - f*f) * (b*b + c*c - f*f)
                  - b*b * (a*a + c*c - e*e) * (a*a + c*c - e*e)
                  - c*c * (a*a + b*b - d*d) * (a*a + b*b - d*d)
                  + (a*a + b*b -d*d) * (a*a + c*c - e*e) * (b*b + c*c - f*f)
                    ) / 12 ;
        printf("%.4f\n", v);
    }
    return 0;
}


 

校庆神秘建筑

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1923    Accepted Submission(s): 631

Problem Description
杭州电子科技大学即将迎来50周年的校庆,作为校庆委员会成员的我被上级要求设计一座神秘的建筑物来迎合校庆,因此我苦思冥想了一个月,终于设计出了一套方案,这座建筑物有点象古老埃及的金字塔,不过这个神秘建筑的根基是三角形的而不是矩形的,从数学的专业角度来讲,它是四面体。当我打算上交我的设计图纸的时候发现,我不知道怎么计算这个神秘建筑的体积(我知道这座建筑的各边的尺寸),于是我找来了聪明的你来帮助我解决这个难题。
 

Input
输入文件包含6个不超过1000的实数,每个数之间用空格隔开。每个数代表金字塔ABCD的一条棱边长度,棱边排序如下:AB,AC,AD,BC,BD,CD。
 

Output
输出数据应是一个实数,表示金字塔的体积,精确到4位小数。
 

Sample Input
   
   
2 2 2 2 2 2
 

Sample Output
   
   
0.9428
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#define inf 0x3f3f3f3f
#define N 1001
using namespace std;

int main()
{
    double a, b, c, d, e, f;           // 用int 会 Output Limit Exceeded,七夕刷题遍地坑。。
    while(~scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f))
    {
        double v = sqrt
                    (
                    4*a*a*b*b*c*c
                  - a*a * (b*b + c*c - f*f) * (b*b + c*c - f*f)
                  - b*b * (a*a + c*c - e*e) * (a*a + c*c - e*e)
                  - c*c * (a*a + b*b - d*d) * (a*a + b*b - d*d)
                  + (a*a + b*b -d*d) * (a*a + c*c - e*e) * (b*b + c*c - f*f)
                    ) /12 ;
        printf("%.4lf\n", v);
    }
    return 0;
}



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值