#P16588. [GKS 2016 #D] Vote

    ID: 16561 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>2016Special JudgeGoogle Kick Start

[GKS 2016 #D] Vote

题目描述

A and B are the only two candidates competing in a certain election. We know from polls that exactly NN voters support A, and exactly MM voters support B. We also know that NN is greater than MM, so A will win.

Voters will show up at the polling place one at a time, in an order chosen uniformly at random from all possible (N+M)!(N + M)! orders. After each voter casts their vote, the polling place worker will update the results and note which candidate (if any) is winning so far. (If the votes are tied, neither candidate is considered to be winning.)

What is the probability that A stays in the lead the entire time -- that is, that A will always be winning after every vote?

输入格式

The input starts with one line containing one integer TT, which is the number of test cases. Each test case consists of one line with two integers NN and MM: the numbers of voters supporting A and B, respectively.

输出格式

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the probability that A will always be winning after every vote.

yy will be considered correct if yy is within an absolute or relative error of 10610^{-6} of the correct answer.

2
2 1
1 0
Case #1: 0.33333333
Case #2: 1.00000000

提示

In sample case #1, there are 33 voters. Two of them support A -- we will call them A1 and A2 -- and one of them supports B. They can come to vote in six possible orders: A1 A2 B, A2 A1 B, A1 B A2, A2 B A1, B A1 A2, B A2 A1. Only the first two of those orders guarantee that Candidate A is winning after every vote. (For example, if the order is A1 B A2, then Candidate A is winning after the first vote but tied after the second vote.) So the answer is 2/6=0.333333...2/6 = 0.333333...

In sample case #2, there is only 11 voter, and that voter supports A. There is only one possible order of arrival, and A will be winning after the one and only vote.

Limits

1T1001 \le T \le 100.

Small dataset (Test set 1 - Visible)

0M<N100 \le M < N \le 10.

Large dataset (Test set 2 - Hidden)

0M<N20000 \le M < N \le 2000.