Rotation Transformation
Time limit2sMemory limit1024 MB
Given a 3x3 rotation matrix, find the rotation angle in degrees and the unit axis vector that produce it.
Problem
Julia loves simple motions very much, especially in three-dimensional space. Recently she found a matrix that corresponds to a rotation around an axis through the origin. The rotation is defined by a unit vector and a rotation angle .
Look at the origin from the end of . If the rotation is counter-clockwise, then is positive. Otherwise, is negative.
The rotation matrix moves a point to as follows.
Julia does not know the values of and . She asks you to recover them so she can continue her simple motion.
Input
You are given the matrix . It is guaranteed that there is a rotation matrix with for all and .
Output
On the first line, print the angle in degrees. On the second line, print the coordinates of the unit vector . It is guaranteed that . Print every number as precisely as you can. Your answer is accepted if the difference between each and the matrix built from your angle and unit vector does not exceed .