spoj#RANAGIC. Random Magic Trick
Random Magic Trick
A standard deck of cards has 52 cards in total, 4 suits - Hearts, Diamonds, Clubs, and Spades and each suit has 13 cards (2, 3, 4, 5, 6, 7, 8, 9, 10, Jacks, Queens, Kings and Aces). Oompa Loompa is an amateur magician who loves card magics. As you know, many magic tricks are rather simple once you know the secret behind them. Oompa Loompa's favorite trick is the random magic trick. The trick goes on like this. At first, he takes a deck of cards consisting of some suits, and each suit containing some cards, and randomly shuffles them. The magician's trick here is to show there are at least 2 consecutive Kings as well as 2 consecutive Queens in the shuffled deck. As you can see, this trick relies on pure luck, and may be unsuccessful if the magician's luck runs out :)
Performing the trick with a non-standard deck of cards, with any number of suits and any number of cards in each suit, what is the probability of performing a successful magic trick?
Note:
<li>Assume that the deck is shuffled uniformly randomly.</li> <li>Assume that any suit contains at least two cards, and every suit contains the king card and the queen card.</li>A suit consists of distinct cards numbered from 1 to C, and the cards numbered 1 and 2 are Kings and Queens respectively. Note that any card is uniquely identified by its suit and card number.
Input
The first line contains T denoting the number of test cases. Each of the next T lines consists of two space-separated integers S and C, denoting the number of suits and the number of cards in each suit respectively.Constraints
<li>1 ≤ T ≤ 1692 </li><li>1 ≤ S ≤ 36 </li><li>2 ≤ C ≤ 48Output
For each test case, print the probability of the magician performing a successful magic trick. An absolute error less than 10-6 will be ignored.Sample Input
2 2 2 2 3
Sample Output
0.333333333333 0.133333333333