首页 > 代码库 > HDU_5810:Balls and Boxes(期望)

HDU_5810:Balls and Boxes(期望)

这题似乎就是纯概率论。。

E(V)=D(X_i)=npq  (p=1/m,p+q=1)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

LL n,m;
LL gcd(LL a,LL b)
{
    return b?gcd(b,a%b):a;
}

int main()
{
    while(cin>>n>>m && n+m)
    {
        LL a=n*m-n,b=m*m;
        LL g=gcd(a,b);
        cout<<a/g<</<<b/g<<endl;
    }
}

 

HDU_5810:Balls and Boxes(期望)