Prime Cut 4

View as PDF

Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Waahahaha, I'm a Wario!

I need your help to win a game. I have steak that is in the shape of a rectangular prism with an arbitrary position, rotation and scale. I want to cut the steak into 2 pieces with a flat cut such that the volume of the pieces are equal. But, the Laser-cutter-3000 I got Penny to make cannot rotate, and always cuts the steak on the YZ plane.

I can define an x_i value for the laser cutter such that the steak is cut by the plane x = x_i.

Can you find the value of x_i such that the plane x = x_i will bisect the steak?

Input

There are 8 lines, one for each vertex of the steak.

Each line has 3 integers, x y z, giving the 3-dimensional coordinate of the vertex.

It is guaranteed these 8 coordinates form the vertices of a rectangular prism.

Output

Give me the x-value of the plane that divides the steak in 2. Answers with a relative or absolute error less than 10^{-3} will be accepted.

Constraints

  • -10^4 \le x, y, z \le 10^4

Example 1

Input
0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 0 1
1 1 0
1 1 1
Output
0.5

Here is a diagram of the prism and the plane that bisects it.

Example 2

Input
0 4 0
3 0 0
3 0 6
7 3 6
7 3 0
4 7 0
0 4 6
4 7 6
Output
3.5

Here is a diagram of the rotated prism and the plane that bisects it.


Comments

There are no comments at the moment.