A |
Convex Orthogonal Polygon Input: Standard Input Output: Standard Output |
In Cartesian coordinate system a lattice point is a point whose abscissa and ordinate is integer. For example (3, 4) is a lattice point but (4.5, -10) is not a lattice point. If all the vertices of a polygon are lattice points then this polygon is called a lattice polygon. For this problem a lattice polygon is orthogonal when all its sides are parallel to x-axis or y-axis. An orthogonal lattice polygon is convex when there is no such horizontal or vertical line segment that connects two points within the polygon and has some parts of it outside the polygon. The bounding box of an orthogonal convex polygon is the smallest rectangle (With axis-parallel sides) that contains the entire polygon.
Figure 1: A orthogonal convex polygon and its bounding box (Shown with red). |
Figure 2: A orthogonal concave polygon and its bounding box (Shown with red) |
Figure 3: At step zero we have a polygon which is painted dark blue. The growth in step 1 and 2 are shown by filling them with lighter blue colors. |
Now you have to deal with the growth of a Orthogonal Convex lattice polygon. Suppose the area of an orthogonal convex lattice polygon (OCLP) at step zero is A0 and the area of its bounding box is B0. But you have forgotten other details about this polygon (Like coordinate of its vertices). In the next step this polygon grows by one unit in horizontal and vertical direction as shown in the figure 3 and its area becomes A1. This process continues and after n steps the area of the polygon becomes An. Now given the value of A0, An and B0 you will have to find out the value of n if possible.
Input file can contain up to 50000 lines of inputs. Each line contains three positive integers which denotes the values of A0 (0<A0≤10000), An (A0≤An≤1018) and B0 (0< B0<20000) respectively.
Input is terminated by a line containing three zeroes. This case need not be processed.
For each line of input produce one or more lines of output. These lines contain the possible values of n (one in each line). If there is more than one possible value of n print those in ascending order. If the given input values are impossible print a -1 instead.
Print a blank line after the output for each set of input.
1 25 1 7 20 7 7 21 7 8 20 7 0 0 0 |
2 -1 -1 -1 |
Problemsetter: Shahriar Manzoor
Moderator: Derek Kisman