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 Input2 2 2 2 2 2
Sample Output0.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; }