主页 讨论版 问题 名次 状态 统计
欢迎加入西电微软俱乐部招新群 588166170,做出福利题,免技术部第一次面试且赠送“福利”海报或小礼品~~~~
问题 F: Furude_Rika and game

问题 F: Furude_Rika and game

时间限制: 1 Sec  内存限制: 128 MB
提交: 21  解决: 12
[提交][状态][讨论版]

题目描述

Furude_Rika is so boring so she plays a game with herself.
She has a matrix consisting m rows and n columns and all of its element are "1"s.
In each second she can choose one element with equal probility.
if it is "1",she will change it to "0",otherwise she ignore it.
If there is at least one "0" on each row and at least one "0" on each column,the game ends.
Furude_Rika wants to calculate the expected time needed to finish this game.
As she is only a little girl,can you help her?

输入

The first line contains an integer T, indicates the number of test case. (T<=15)

Next T lines contains two integers m and n,indicates the number of rows and the number of lines.(m<=2000,n<=2000)

输出

For each test case, output one line, the expected time needed to finish this game.

The answer is round to three digit.

样例输入

3
1 1
1 2
2 2

样例输出

1.000
3.000
3.667

提示

for m=1,n=2.


the expect time is:1*0+2*1/2+3*1/4+4*1/8+5*1/16+……=3.000

[提交][状态][讨论版]