This page is still under construction.

Parts of this page are still being built. What you see may change.

Cake Corner Trimming

Time limit1sMemory limit256 MB

Summary
Choose the largest corner-trim parameter s so the convex polygon keeps at most fraction a of its area.
Level

Medium5 of 10

Topics
Geometry, Math, Binary search
Solved
No attempts yet

Problem

Sophie likes to bake cakes and share them with friends. For the wedding of her best friend Bea she baked a very special cake from the best ingredients she could find and put a picture of the engaged couple on top. To make it even more special she did not make it round or square, but cut it into a convex shape of her own design. Sophie decided to send the cake to the party with a specialist carrier. The cake turned out to be a little heavier than the standard cake package allows, and the overweight fee is steep, so Sophie decided to remove part of the cake to make it lighter.

Sophie cuts the cake as follows. First she picks a real number s≥2s \ge 2. At every vertex she marks, on each of the two edges that meet there, the point at 1/s1/s of that edge's length measured from the vertex. She then makes a straight cut between the two marks of that vertex and removes the vertex. She does this once at every vertex.

The figure shows the first two sample inputs.

Assume the weight is spread uniformly over the area of the cake. Sophie does not want to cut away more than she has to. Work out how she should choose ss.

Input

The first line contains a real number aa and an integer NN, where aa is the fraction of the cake's weight that the carrier allows and NN is the number of vertices of the cake (0.25≤a<10.25 \le a < 1, 3≤N≤1003 \le N \le 100). aa is given with at most 7 digits after the decimal point.

Each of the next NN lines contains two integers xix_i and yiy_i, the coordinates of one vertex of the cake (0≤xi,yi≤1080 \le x_i, y_i \le 10^8). The vertices are given in the order in which they form a strictly convex polygon, either clockwise or counterclockwise.

There is always an ss with 2≤s≤10002 \le s \le 1000 that leaves exactly the fraction aa of the original weight.

Output

Print, on one line, the largest ss for which the remaining cake weighs at most the fraction aa of the original weight. Round the value at the seventh digit after the decimal point and print all six digits after the decimal point.

Examples4

  1. Example 1

    Input
    0.875 4
    0 0
    8 0
    8 4
    0 4
    
    Expected output
    4.000000
    
  2. Example 2

    Input
    0.85 5
    6 0
    12 6
    9 12
    0 12
    3 3
    
    Expected output
    3.000000
    
  3. Example 3

    Input
    0.999998 4
    20008 10000
    15004 15005
    10001 20009
    15005 15004
    
    Expected output
    1000.000000
    
  4. Example 4

    Input
    0.25 3
    0 0
    4 0
    0 3
    
    Expected output
    2.000000