Problem E
Easter Holidays
Scandinavians often make vacation during the Easter holidays in the largest ski resort Åre. Åre provides fantastic ski conditions, many ski lifts and slopes of various difficulty profiles. However, some lifts go faster than others, and some are so popular that a queue forms at the bottom.
Per is a beginner skier and he is afraid of lifts, even though he wants to ski as much as possible. Now he sees that he can take several different lifts and then many different slopes or some other lifts, and this freedom of choice is starting to be too puzzling...
He would like to make a ski journey that:
-
starts at the bottom of some lift and ends at that same spot
-
has only two phases: in the first phase, he takes one or more lifts up, in the second phase, he will ski all the way down back to where he started
-
is least scary, that is the ratio of the time spent on the slopes to the time spent on the lifts or waiting for the lifts is the largest possible.
Can you help Per find the least scary ski journey?
A ski resort contains
Input
The first line of the input contains the number of cases –
the number of ski resorts to process. Each ski resort is
described as follows: the first line contains three integers
Output
For each input case, the program should print two lines. The first line should contain a space-separated list of places in the order they will be visited – the first place should be the same as the last place. The second line should contain the ratio of the time spent in the slopes to the time spent on the lifts or waiting for the lifts. The ratio should be rounded to the closest 1/1000th. If there are two possibilities, then the rounding is away from zero (e.g., 1.9812 and 1.9806 become 1.981, 3.1335 becomes 3.134, and 3.1345 becomes 3.135). If there are multiple journeys that prior to rounding are equally scary, print an arbitrary one.
Sample Input 1 | Sample Output 1 |
---|---|
1 5 4 3 1 3 12 2 3 6 3 4 9 5 4 9 4 5 12 5 1 12 4 2 18 |
4 5 1 3 4 0.875 |