| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 买学问 - 大牛一对一辅导，有问必答 买学问 - 专业的付费知识问答平台

498. Coins
498.硬币
Time limit per test: 0.75 second(s)

Memory limit: 262144 kilobytes

input: standard
output: standard

Andrew has just made a breakthrough in gambling: he has invented a way to make coins which have probability p of landing heads-up and 1 - p of landing tails-up when tossed, where p is some number between 0 and 1.
Andrew近来在赌博上取得重大突破：他发明了一种方法来赚取硬币，就是那种在投掷时有p的概率正面朝上和1-p的概率反面朝上的硬币，p是某个在0和1之间的数。
He can't, however, control the number p itself, and creates coins with any p from 0 to 1 with equal probability.

That is, the value of p is a random value uniformly distributed on  .

Andrew has generated two coins independently.
Andrew已经互相独立地准备了两枚硬币。
One with probability p and another with probability q of landing heads-up.

Random values p and q are both uniformly distributed on  and are independent.

Of course, neither Andrew nor we know the numbers p and q, we can only try to guess them using our observations.

The observations are the following: the first coin was tossed n1 times, and m1 of them landed heads-up. The second coin was tossed n2 times, and m2 of them landed heads-up. Your task is to compute the probability that p < q.

Input
The first line of the input file contains one integer T ( ) ― the number of test cases to solve. Each of the following T lines contains 4 integers each: n1, m1, n2, m2. 1 ≤ n1, n2 ≤ 1000, 0 ≤ m1, m2 ≤ 50, 0 ≤ m1 ≤ n1, 0 ≤ m2 ≤ n2.

Output
For each test case output one line with a floating-point number, the probability of p < q. Your answer will be considered correct if it is within 10-4 of the right answer.

Example(s)
sample input    sample output
4
2 1 4 3     0.7142857142
8 4 16 8    0.5000000000
2 0 6 1     0.5333333333
2 0 2 1     0.8000000000    • 1
• 1/1页
• • 1
• 