Ball in a hexagon#1448

Ball in a hexagon

1 second
64 megabytes
Very hard

In the Cartesian coordinate system , a regular hexagon is drawn. Each side of the hexagon has length and each angle is degrees (because it is regular). The center of the hexagon is at , and two of its vertices are at and .

A small round ball is initially placed at and will be treated as a point mass. The ball is struck so that it starts moving at a constant speed of one unit segment per second (where a unit segment is the segment connecting and ) in the direction making a -degree angle with the positive axis, as shown below:

If, during its motion, the ball touches any side of the hexagon, it is reflected from that side according to the law of reflection—the angle of incidence equals the angle of reflection. The collision is perfectly elastic, so after the reflection, the ball continues to move at the same speed.

If the ball hits a corner of the hexagon exactly, the reflection also occurs according to physical laws: the angle of incidence is measured from one side forming the corner and the angle of reflection from the other.

Assume that after exactly seconds of motion, the ball is at the point (x_0, y_0). Write a program that takes as input and finds the value of x_0^2 + y_0^2.

Input

The number is an integer with 1 \leq T \leq 1\,000\,000\,000.

Output

Output a single line containing the decimal representation of the real number , where S = x_0^2 + y_0^2. The number should be rounded to exactly decimal places according to standard mathematical rounding rules.

All test cases guarantee that is at least away from the nearest half-integer (that is, a number of the form x + 0.5 for integer ) to avoid rounding problems due to computation errors.

Examples

Example 1

Loading
Loading