main idea
Given \ (N, M, K \) , represents a \ (N * N \) null matrix, \ (M \) different numbers.
The random \ (M \) the number of \ (N ^ 2 \) the number of thrown into the empty matrix ( \ (M \ GE N ^ 2 \) )
and from \ (M \) random number in option \ (K \) different numbers in these matrix \ (K \) the number of marked (if any).
Set \ (T \) value of the number of completely labeled aligned entire row.
Seeking \ (2 ^ T \) expectations and \ (1e99 \) of a smaller value.
Thinking
First, \ (2 ^ T \) such a strange thing, we can be understood as the number of all sub-set of cases.
That in some cases might be counted more than once is legal, so do not inclusion and exclusion.
The answer is that all of the \ (T \) value of the expected value of the number appears.
Then there is a more obvious idea: wish to enumerate what \ (R, C \) , represents at least there \ (R \) the entire line, \ (C \) entire column is marked complete.
At this point there is a \ (C (N, R) \ times C (N, C) \) represents the case in which the \ (T \) the total number of values.
The probability of occurrence of such programs \ (P [R] [C ] \) values divided by total number of cases it is this situation.
We may assume \ (the Z = (C + R & lt) \ Times NR \ Times C \) , i.e. which \ (the Z \) number will be selected in the \ (K \) number of.
There:
\ [P [R & lt] [C] = \ FRAC {C (M, K) \ CDOT A (K, the Z) \ CDOT A (the MZ, N ^ 2-the Z)} {C (M, K) \ cdot A (M, N ^
2)} \] after the expression simplified to give:
\ [P [R & lt] [C] = \ {C FRAC (the MZ, KZ)} {C (M, K)} \]
That is, the contribution to the case of the answer to \ (C (N, R) \ times C (N, C) \ times \ frac {C (MZ, KZ)} {C (M, K)} \)
Small NOTE:
For \ (P [R] [C ] \) is understood:
- For the first equation understanding:
Molecular: enumerating \ (K \) selection, \ (the Z \) of the selected color, the remaining \ (N ^ 2-Z \ ) of the selected color.
Denominator: Consider the case of each and every color matrix \ (K \) of the total number of program choices. - For understanding the second formulas: pre-coated colors found no effect on the answer to statistics
molecule: \ (Z \) position and the number of colors has been fixed, then this \ (Z \) number must be in \ (K \ ) number, the remaining \ (KZ \) a random selection on the line.
Denominator: Shanghao color matrix has, then the total number of the program only \ (C (M, K) \)
For answers save mode:
use long double
to store a number of log()
values,
the multiplication becomes addition, subtraction becomes division, and finally a uniform solution.
Code
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
#define LD long double
const int MAXN=100005;
int N,M,K;
LD f[MAXN],Ans;
LD C(int x,int y){
return f[x]-f[y]-f[x-y];
}
int main(){
scanf("%d%d%d",&N,&M,&K);
for(int i=1;i<=1e5;i++)
f[i]=f[i-1]+log(1.0*i);
for(int i=0;i<=N;i++)
for(int j=0;j<=N;j++){
int z=N*(i+j)-i*j;
if(z>K)continue;
LD tmp=C(N,i)+C(N,j)+C(M-z,K-z)-C(M,K);
Ans=min((LD)(1e99),Ans+exp(tmp));
}
printf("%.10f\n",(double)Ans);
}