406042: GYM102222 D Take Your Seat

Memory Limit:256 MB Time Limit:10 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Take Your Seattime limit per test10 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Duha decided to have a trip to Singapore by plane.

The airplane had $$$n$$$ seats numbered from $$$1$$$ to $$$n$$$, and $$$n$$$ passengers including Duha which were also counted from $$$1$$$ to $$$n$$$. The passenger with number $$$i$$$ held the ticket corresponding to the seat with number $$$i$$$, and Duha was the number $$$1$$$ passenger.

All passengers got on the plane in the order of their numbers from $$$1$$$ to $$$n$$$. However, before they got on the plane Duha lost his ticket (and Duha was the only passenger who lost the ticket), so he could not take his seat correctly. He decided to take a seat randomly. And after that, while a passenger got on the plane and found that his/her seat has been occupied, he/she selected an empty seat randomly as well. A passenger except Duha selected the seat displayed in his/her ticket if it had not been occupied by someone else.

The first problem you are asked to calculate in this problem is the probability of the last passenger to get on the plane that took his/her correct seat.

Several days later, Duha finished his travel in Singapore, and he had a great time.

On the way back, he lost his ticket again. And at this time, the airplane had $$$m$$$ seats numbered from $$$1$$$ to $$$m$$$, and $$$m$$$ passengers including Duha which were also counted from $$$1$$$ to $$$m$$$. The passenger with number $$$i$$$ held the ticket corresponding to the seat with number $$$i$$$, and Duha was the number $$$1$$$ passenger as well.

The difference was that: all passengers got on the plane in a random order (which was any one of the $$$m!$$$ different orders with the same chance). Similarly, Duha or a passenger who found his/her seat had been occupied selected an empty seat randomly.

The second problem you are asked to calculate in this problem is the probability of the last passenger to get on the plane that took his/her right seat on the return trip.

Input

The input contains several test cases, and the first line is a positive integer $$$T$$$ indicating the number of test cases which is up to $$$50$$$.

For each test case, a line contains two integers $$$n$$$ and $$$m~(1\le n, m\le 50)$$$.

Output

For each test case, output a line containing Case #x: y z, where x is the test case number starting from $$$1$$$, y is the answer of the first problem, and z is the answer of the second problem. Both of y and z are rounded to $$$6$$$ places, and we guarantee that their $$$7$$$-th places after the decimal point in the precise answer would not be $$$4$$$ or $$$5$$$.

ExampleInput
1
2 3
Output
Case #1: 0.500000 0.666667

加入题单

上一题 下一题 算法标签: