Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 1120
Chairlift

Time Limit: 2 Seconds      Memory Limit: 65536 KB

A chairlift is used to transport skiers (or summer sightseers) up the mountain. Figure 1 shows the components of a chairlift, viewed from the air above the chairlift:

A closed-loop steel cable is in continuous motion around two rotating wheels (one at the bottom, one at the top of the mountain).

There are N equally spaced chairs suspended from the cable. N is an even integer, 18 <= N <= 300. In Figure 1, N = 18. The chairs are shown as short dashes across the cable. You must understand that Figure 1 is a ��snapshot��, i.e., that the chairs are in continuous motion along with the cable.

The circumference of each wheel is equal to the distance between adjacent chairs.

Passengers ride up in the chairs on the ��upward bound�� side of the lift; the chairs come back down empty on the ��downward bound�� side.

The loading station (see Figure 2) is located on the lift��s upward bound side, at the point of tangency between the cable and the wheel at the bottom of the mountain. When a chair goes by the loading station, passengers will quickly board the chair; the chair doesn��t stop. (Each chair is actually a bench , it can hold up to 4 people.)

The unloading station (see Figure 3) is also located on the lift��s upward bound side, at the point of tangency between the cable and the wheel at the top of the mountain. When a chair goes by the unloading station, passengers will quickly get off the chair; the chair doesn��t stop.

The chairs are numbered in the order in which they appear at the loading station when the lift is first activated in the morning. That is, they are numbered starting at 1, increasing sequentially in a direction opposite to the direction of motion. Figure 4 is a reproduction of Figure 1, showing chair numbers for the case N = 18. (Remember that the figure is just a ��snapshot��, the chairs are in continuous motion.)

Now that you are familiar with the chairlift, it is time to state the problem. Two friends, whom we shall call Bob and Alice, are out for a day of skiing. They are just riding up in chair 56 and know that the lift has 126 chairs. They also know that the ride from the loading station to the unloading station takes exactly 225.0 seconds. Bob asks Alice: ��How much longer will the ride take?�� Alice doesn��t look at her watch. Instead, she waits until their chair meets a downward bound empty chair, notes that the number of that chair is 71, and replies: ��We have 198.9 more seconds to go.�� (An upward bound chair and a downward bound chair ��meet�� when they are exactly opposite each other (i.e., both chairs are equidistant from the top of the mountain). At the instant shown in Figure 4, no two chairs meet, but very soon thereafter, chairs 6 and 7, as well as chairs 5 and 8, etc., would meet.)

Your program will carry out Alice��s computations.

Sample Input

```126 225.0
56 71
31 120
100 53
```

Sample Output

```Program 1 by team X
N = 126, T = 225.0
Chair  56 meets chair  71, remaining time = 198.9
Chair  31 meets chair 120, remaining time =  65.7
Chair 100 meets chair  53, remaining time =  83.7
End of program 1 by team X
```

The first line of the input file will contain N, followed by T. The constraints on N were previously stated. T (the time it takes to ride from the loading station to the unloading station) is a floating point number, measured in seconds, 200.0 <= T <= 999.9. The first line will be followed by one or more additional lines of input. On each of these additional lines, there will be exactly two integer values in the range 1..N, representing two distinct chairs. The first of these chairs is the upward bound chair in which Bob and Alice are riding. The second chair is the downward bound chair they meet when Alice announces the remaining time.

After displaying N and T, the program will produce one line of output, containing the two chair numbers and the remaining time, for each pair of chairs in the input.

Pay attention to all formatting details, such as punctuation, upper/lower case letters, the alignment of certain words, blank spaces, and the absence of blanks lines.

Here is a formatting template shown between two lines of the above output:

```N = 126, T = 225.0
1234567890123456789012345678901234567890123456789
Chair  56 meets chair  71, remaining time = 198.9
```

Note in particular, that

all numerica l values are right-justified in the output fields shown by the formatting template;

floating point values (representing seconds) will be displayed with one digit following the decimal point.

Source: Rocky Mountain 2000
Submit    Status