标签:style blog color io os ar for sp div
#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; }
CodeForces 452C Magic Trick (排列组合)
标签:style blog color io os ar for sp div
原文地址:http://www.cnblogs.com/woshijishu3/p/4020265.html