标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 260 Accepted Submission(s): 187
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #include <vector> #include <queue> #include <cstring> #include <string> #include <algorithm> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MM(a,b) memset(a,b,sizeof(a)); #define inf 0x7f7f7f7f #define FOR(i,n) for(int i=1;i<=n;i++) #define CT continue; #define PF printf #define SC scanf const int mod=1000000007; const int N=1e3+10; ll gcd(ll a,ll b) { if(b==0) return a; else return gcd(b,a%b); } int main() { ll n,m; while(~scanf("%lld%lld",&n,&m)&&(n||m)) { ll fenzi=n*(m-1),fenmu=m*m; while(1) { ll k=gcd(fenzi,fenmu); if(k==1) break; fenzi/=k;fenmu/=k; } printf("%lld/%lld\n",fenzi,fenmu); } return 0; }
分析:比赛时就感觉是个什么分布,,但是学的很多又忘了,最后百度了一下,才发现可以二项分布做;
对于每个盒子,每个球落入其中的概率是p=1/m;
那么总共n个球p(x=k)=C(n,k)*p^k*(1-p)^(n-k),显然的二项分布;
二项分布数学期望E(x)=np(n是实验次数,p是每次试验球落入盒子的概率);
方差D(x)=np(1-p)
本题中D(x)=n/m*(1-1/m)=n*(m-1)/(m^2);
标签:
原文地址:http://www.cnblogs.com/smilesundream/p/5755971.html