Problem I
Normals
Input: Standard Input

Output: Standard Output

Time Limit: 2 Seconds


Think of a very simple ellipse whose center is the origin and axes are along x-axis and y-axis. (p,q) is an arbitrary point. From (p, q) you can draw at most four normals on the ellipse as shown in the pictures below. Given a scenario your job is to determine all the points on the ellipse where the normals can be drawn (In the first figure four and in the second figure two). 


Input 

The input file contains less than 50 lines of inputs. Each line contains four integers a, b, p, q. Here a is half of the length of the axis of the ellipse along x-axis and b is half of the length of the axis of the ellipse along y-axis and (p,q) is the point from where the normals are to be drawn. Note that 0<a,b<=300, 0<=|p|, |q|<=300, a, b are never equal and p is never on the ellipse. Input is terminated by a case whose value of a<0. This case should not be processed.

 

Output 

For each line of input produce three to five lines of outputs. The first line is the serial number of the input. Each of the next lines (Maximum four) contain coordinate of one point. These points are the coordinates of points on the ellipse where the normals can be drawn. These points should be ordered in ascending order of x-axis and then in ascending order of y-axis. All these points should be different. Two points are considered same when their distance is less than 10-5. All printed numbers should have five digits after the decimal point. Errors less than 10-5 will be ignored. 

 

Sample Input    Output for Sample Input      Comment

100 50 10 10
100 50 80 80
-1 10 10 10

Case 1:

-99.82691 -2.94058

12.49383 49.60823

14.29631 -49.48640

99.70343 -3.84791

Case 2:

-96.72990 -12.68194

63.18715 38.75366

The first Figure corresponds to the first sample input/output and the second figure corresponds to the second sample input/output.

 


Problemsetter: Shahriar Manzoor, Member of Elite Problemsetters' Panel
Special Thanks to Derek Kisman (Alternate Solution)