The Falling Pillars

The problem we will now discuss is shown in the picture below. Initially, five pillars are standing upright as shown in Figure 1. Here A is the rightmost point of the base of leftmost pillar. B, C, D and E are similar points for pillar 2, 3, 4 and 5 respectively. The pillars are placed at equal distance. So AB = BC = CD = DE = d. The pillars are allowed to fall somewhat freely from right to left. If the pillars are numbered 1, 2, 3, 4, 5 from left to right then 1 touches 2 at P, 2 touches 3 at Q, 3 touches 4 at R and 4 touches 5 at S. The widths of all the pillars are w (as shown in an inset in Figure 2) and heights of all the pillars are h. Note that Figure 1, Figure 2 and the Figure below are described as 2-D pictures, which is quite OK for this problem. You must also assume that all the pillars are rectangular and no sliding or lifting occurs when the pillars fall down. Your job is to find out the angles SDE, RCD, QBC, PAB in Figure 2 or other such angles in similar scenario.

2/3 There is one additional problem, which is shown in the picture above. In the left configuration the fallen pillar is stable but on the right configuration the fallen pillar is not stable. The cause is explained in the figure itself. Of course, that cause is applicable only when the pillar stands on a single point (In this case point C). A situation is unstable only when a fallen pillar cannot maintain that fallen position on it’s own. A fallen pillar means, the status of a pillar when it falls towards right as much as it is allowed to by the given configuration. You will have to detect if such situation occurs in any of our pillars and report it in the output. Let’s call this situation “Unstable Situation.”. Input The first line of the input file contains a single integer N(N ≤ 20) which indicates how many sets of inputs are there. Each of the next N lines contains one set of input. Each line contains four integers n, d, h and w (1001 > h,d,w > 0 and h ≥ w). These four integers actually describe a scenario or configuration like the above picture completely. Here n is the number of pillars (0 < n ≤ 8), the meaning of d, h and w are described in the problem statement above. Output For each set of input you need to output maximum of n lines. The description of the output for each set is given below: The output for each set starts with the serial number of the set as shown in the output for sample input. Note that there is no space just before the colon (:). If the situation is unstable you should first output the line ‘Unstable Situation.’, without the quotes. The next (n − 1) lines will print the angles of pillars (from right to left) rounded up-to three digits after the decimal point. But if within the given constraints the input is impossible you should only output the line ‘Impossible.’, without the quotes. There will be no such input where a fallen pillar has to occupy the floor where once there was the base of the pillar to it’s right. Remember that you should assume that all pillars should be in fallen status even if all pillars are unstable. Sample Input 2 5 4 10 3 5 4 10 1

3/3 Sample Output Case 1: Unstable Situation. 84.261 78.637 73.349 68.575 Case 2: 72.542 56.188 42.753 32.876