Poj 2208 pyramids (Euler's four-dimensional formula)

Source: Internet
Author: User
Tags integer numbers
Pyramids
Time limit:1000 ms   Memory limit:65536 K
Total submissions:2268   Accepted:751   Special Judge

Description

Recently in Farland, a country in Asia, a famous scientist mr. log ARCHEO has discovered encryption ent 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 Co Nnection with Farland login ent 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

Derivation and proof process of Euler's four-dimensional Formula

1. x, y, and z Cartesian coordinate systems are recommended. Set the coordinates of A, B, and C to (A1, B1, C1), (A2, B2, C2), (A3, B3, C3 ), the six edges of the O-ABC are L, M, N, P, Q, R;

2. Because we don't know how to create a vector, I have inserted an image,

After this formula is used, the following result is obtained:

3. According to the Coordinate Expression of the vector quantity product and the definition of the quantity product

According to the cosine theorem

4. Bring the above formula into (1) and you will get the legendary Euler's guide formula.

 Code:

# Include <stdio. h> # Include <Math. h>Int  Main (){  Double  P, Q, R, N, M, L;  While (Scanf ( "  % Lf  " , & P, & Q, & R, & N, & M, & L )! = EOF ){  Double Tmp1 = (p * p + q * q-N * N )/ 2  ;  Double Tmp2 = (p * P + R * r-m * m )/ 2 ;  Double Tmp3 = (Q * q + R * r-l * l )/ 2  ;  Double M1 = Q * r * r-tmp3 * Tmp3;  Double M2 = r * tmp1-tmp2 * Tmp3;  Double M3 = tmp1 * tmp3-q * Q * Tmp2;  Double V = SQRT (p * M1-tmp1 * M2 + tmp2 * M3); V /= 6.0 ; Printf (  "  %. 4lf \ n  "  , V );}  Return   0  ;} 

It takes C ++ to pass

G ++ will be wr

Poj is so strange ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.