Responsive image

问题 H: To my boyfriend

问题 H: To my boyfriend

时间限制: 2 Sec  内存限制: 128 MB
提交: 16  解决: 10
[提交][状态][讨论版][命题人:]

题目描述

Dear Liao
I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you teach me?". I replied with a smile, "of course". You replied:"Given a matrix, I randomly choose a sub-matrix, what is the expectation of the number of **different numbers** it contains?"
Sincerely yours,
Guo

输入描述

The first line of input contains an integer T(T≤8) indicating the number of test cases.
Each case contains two integers, n and m (1≤n, m≤100), the number of rows and the number of columns in the grid, respectively.
The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains g_i,j (0≤ g_i,j < n*m).

输出描述

Each case outputs a number that holds 9 decimal places.

样例输入

1
2 3
1 2 1
2 1 2

样例输出

1.666666667

提示

6(size = 1) + 14(size = 2) + 4(size = 3) + 4(size = 4) + 2(size = 6) = 30 / 18 = 6(size = 1) + 7(size = 2) + 2(size = 3) + 2(size = 4) + 1(size = 6)

[提交][状态]
ACM算法攻关部