Under construction

Still being built. Things may change

Build a Boat

Time limit2sMemory limit512 MB

Summary
Split a simple polygon into the largest number of equal-area vertical sections, each of area at least C, and print the bulkhead x-coordinates.
Level

Medium7 of 10

Topics
Geometry, Prefix sum, Binary search
Solved
No attempts yet

Problem

A modern ship survives a collision because of its bulkheads, reinforced vertical walls inside the hull that keep water that has come in from spreading to other sections.

A design team finished the outline of the cross section of a new ship and left the bulkheads out. Placing them is your job.

The cross section is a simple polygon. A bulkhead is a vertical segment that cuts the whole cross section at one x-coordinate, so a set of bulkheads splits the cross section into vertical sections. Every section must have the same area, and that area must be at least CC.

Find the largest number of sections MM that can be made this way, then report where the bulkheads go.

Input

The first line has an integer CC (10≤C≤10910 \le C \le 10^9), the minimum area of one section.

The second line has an integer NN (3≤N≤1053 \le N \le 10^5), the number of vertices of the outline.

Each of the next NN lines has two integers xx and yy (−104≤x,y≤104-10^4 \le x, y \le 10^4), the coordinates of one vertex of the hull. The vertices come in counter-clockwise order.

The outline never doubles back on itself horizontally. A vertical line drawn anywhere passes through the cross section exactly once, never twice.

One section of area CC always fits, and the number of sections MM is between 1 and 100.

Output

On the first line print MM, the largest number of sections of equal area whose common area is at least CC.

Then print M−1M - 1 lines. Line kk holds the x-coordinate of the kk-th bulkhead, placed so that all MM sections have the same area. Print the coordinates in increasing order, each with exactly six digits after the decimal point.

Examples3

  1. Example 1

    Input
    50
    4
    110 10
    80 10
    80 0
    110 0
    
    Expected output
    6
    85.000000
    90.000000
    95.000000
    100.000000
    105.000000
    
  2. Example 2

    Input
    24
    3
    10 10
    30 10
    20 20
    
    Expected output
    4
    17.071068
    20.000000
    22.928932
    
  3. Example 3

    Input
    1280
    10
    100 120
    97 50
    94 99
    74 97
    50 87
    29 71
    13 50
    3 26
    0 0
    100 0
    
    Expected output
    6
    27.501547
    44.320438
    59.004132
    72.700842
    85.849445