#include <iostream> #include <cstdio> #include<cmath> #include<algorithm> using namespace std; double num[1000000]; void init_arrary(){ for (int i = 1; i <= 1000000; ++i) { num[i] = num[i - 1] + log(i); } } double Cn(int m,int n){ return num[m] - num[n] - num[m-n]; } int main(){ double n , m; int i,j; init_arrary(); while(cin >> n >> m){ double sum=0,res; res=0; for(i=1;i<=min(m,n);i++){ sum=Cn(m,i)+Cn(n*m-m,n-i)-Cn(n*m,n); sum=exp(sum); res+=sum*i*i/n;//期望吧 } cout<<res<<endl; } return 0; }
时间: 2024-11-06 19:49:39