Under construction

Still being built. Things may change

I'm a Fan

Interview

Time limit2sMemory limit512 MB

Summary
Find the smallest CCW rotation angle whose swept orbit of a star-shaped polygon around the origin is a full disk.
Level

Hard8 of 10

Topics
Geometry, Math, Binary search, Implementation
Solved
No attempts yet

Problem

Sangsu is a devoted fan of Jinpyo. As a token of his fandom, he gives Jinpyo a fan that he built himself. While playing with it, Jinpyo discovers that once the fan is turned past a certain angle, the path traced by its blades becomes a circle.

Suppose the fan blades lie on a coordinate plane whose origin is the fan's center of rotation. The blades can then be represented as a simple polygon with N vertices that contains the origin. For safety, the blades were designed to satisfy the following condition.

For any point P inside the fan blades, every point on the line segment connecting the origin O to P is also inside the blades.

Find the minimum rotation angle at which the path traced by the blades becomes a circle. The fan turns counterclockwise.

Input

The first line gives the number of vertices N of the fan blades (3 ≤ N ≤ 300,000).

The next N lines give the coordinates of the vertices in counterclockwise order. Each coordinate consists of two integers, an x coordinate and a y coordinate, and the absolute value of each coordinate is at most 10^6.

The polygon contains the origin, and no two sides intersect except for adjacent sides. No three consecutive points of the polygon lie on a single line.

Output

Print the minimum angle θ, in degrees, such that turning the fan counterclockwise by θ makes the path traced by the blades a circle. An absolute or relative error of at most 10^-6 is accepted.

Hint

The fan from the first example is shown below.

Fan from the first example

When it is turned 45° counterclockwise, the traced path is as follows. The first and last shapes are shaded dark.

Path traced when turned 45° counterclockwise

Once it has turned 90°, the traced path becomes a circle of radius 2√2. The answer is therefore 90.

Examples2

  1. Example 1

    Input
    5
    2 2
    -2 2
    -2 -2
    0 -1
    2 -2
    Expected output
    90.000000
  2. Example 2

    Input
    4
    2 2
    2 3
    -2 -2
    -2 -3
    Expected output
    180.000000