zoukankan      html  css  js  c++  java
  • 2016 多校联赛7 Balls and Boxes(概率期望)

    Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner that each ball has equal probability of going to each boxes. After the experiment, he calculated the statistical variance V as 
    V=mi=1(XiX¯)2mV=∑i=1m(Xi−X¯)2m

    where XiXi is the number of balls in the ith box, and X¯X¯ is the average number of balls in a box. 
    Your task is to find out the expected value of V. 

    InputThe input contains multiple test cases. Each case contains two integers n and m (1 <= n, m <= 1000 000 000) in a line. 
    The input is terminated by n = m = 0. 
    OutputFor each case, output the result as A/B in a line, where A/B should be an irreducible fraction. Let B=1 if the result is an integer.Sample Input

    2 1
    2 2
    0 0

    Sample Output

    0/1
    1/2
    
    
            
     

    Hint

    In the second sample, there are four possible outcomes, two outcomes with V = 0 and two outcomes with V = 1.

    概率期望问题,启发博客:http://blog.csdn.net/xzxxzx401/article/details/52167534 以下
      • 首先这是一个二项分布。对于一个盒子来说,n次实验是扔n个球,每次进入盒子概率是1/m。样本方差的期望等于总体的方差!证明爱看不看。直接的结果:E(V)=n(m1)m2

      • 有不用这个性质直接推出公式的。膜大神。

        E(V)=E(ni=0(XiX¯)2)m=E(x2)2nmE(x)+n2m2 
        E(x)=nm 
        E(x2)=D(x)+[Ex]2 
        二项分布,D(x)=n(m1)m2 
        所以带到上面的式子中就变成了E(V)=n(m1)m2

      • 官方题解我是看不懂。

        E[V]=E[mi=1(XiX¯)2m]=E[(XiX¯)2]=E[X2i2XiX¯+X¯2] 
        =E[X2i]2X¯E[Xi]+E[X¯2]=E[X2i]2X¯2+X¯2=E[X2i]n2m2 
        所以关键是要求出E[X2i]. 我们用随机变量Yj来表示第j个球是否在第i个盒子中,如果在则Yj=1,否则Yj=0. 于是 
        E[X2i]=E[(nj=1Yj)2]=E[nj=1Y2j]+2E[nj=1nk=1,kjYjYk]=nE[Y2j]+n(n1)E[YjYk] 
        =nm+n(n1)m2 
        因此, 
        E[V]=nm+n(n1)m2n2m2=n(m1)m2

    
    
     1 #include<iostream>
     2 #include<cstdio>
     3 using namespace std;
     4 
     5 long long gcd(long long b,long long c)//计算最大公约数
     6 {
     7 return c==0?b:gcd(c,b%c);
     8 }
     9 
    10 int main()
    11 {
    12     long long n,m;
    13     long long a,b;
    14     while(~scanf("%lld%lld",&n,&m)&&(n+m))
    15     {
    16         a=n*(m-1);
    17         if(a==0)
    18             printf("0/1
    ");
    19         else
    20         {
    21             b=m*m;
    22             long long g=gcd(a,b);
    23             printf("%lld/%lld
    ",a/g,b/g);
    24         }
    25     }
    26     return 0;
    27 }
    
    
    
     
  • 相关阅读:
    windows下设置sublime
    sublime编辑器快捷键
    Navicat Premium 12.1.8.0安装与激活
    Win查找弹窗广告来源
    canvas-绘制时钟
    H5标签-canvas实现颜色拾取功能
    第一次Sprint团队贡献分
    Sprint第一个冲刺(第十一天)
    Sprint第一个冲刺(第十天)
    Sprint第一个冲刺(第九天)
  • 原文地址:https://www.cnblogs.com/Annetree/p/7168783.html
Copyright © 2011-2022 走看看