官方题解看不太懂,参考了一些人的博客以后自己证明如下:

其中D(X)和E(X)的公式如下(参考自百度百科):

其中 p = 1 / m 。(这是每一个单独事件发生的概率期望,在这里单独事件指的是一个球放到m个盒子里面,放到每个盒子里面的概率都是一样的,所以期望都是1 / m了)

  推出了公式以后,代码就很好写了。代码如下:

 #include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long ll; int main()
{
int n,m;
while(scanf("%d%d",&n,&m)==)
{
if(n== && m==) break;
ll a = 1LL * n * m - n;
ll b = 1LL * m * m;
if(a==)
{
printf("0/1\n");
continue;
}
ll g = __gcd(a,b);
printf("%I64d/%I64d\n",a/g,b/g);
}
}

  此外,还想提的一点是,网上很多博客包括仓鼠学长都是用猜想的方式推出公式的,其实猜想也是有技巧的,猜想也是包含了运气和经验成分在里面的。过程如下:

  

  看来以后这方面的能力也要提高啊=。=

HDU 5810 Balls and Boxes ——(数学,概率,方差)的更多相关文章

  1. HDU 5810 Balls and Boxes 数学

    Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...

  2. HDU 5810 Balls and Boxes(盒子与球)

     Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/O ...

  3. HDU 5810 Balls and Boxes (找规律)

    Balls and Boxes 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...

  4. hdu 5810 Balls and Boxes 二项分布

    Balls and Boxes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  5. HDU 5810 Balls and Boxes

    n*(m-1)/(m*m) #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio&g ...

  6. hdu 5810:Balls and Boxes(期望)

    题目链接 这题似乎就是纯概率论.. E(V)=D(X_i)=npq (p=1/m,p+q=1) #include<bits/stdc++.h> using namespace std; t ...

  7. 2016 多校联赛7 Balls and Boxes(概率期望)

    Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. ...

  8. HDU_5810_数学,概率,方差

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5810 大意:将n个球往m个盒子中投,每个球被投入每个盒子的概率相等,求方差. 看题解说,这是二项分布( ...

  9. HDU 4611 Balls Rearrangement (数学-思维逻辑题)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4611 题意:给你一个N.A.B,要你求 AC代码: #include <iostream> ...

随机推荐

  1. ASP.NET Core MVC里面Razor如何获取URL参数

    原文:ASP.NET Core MVC里面Razor如何获取URL参数 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https:// ...

  2. WPF 键盘事件

    private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.KeyStates==Keyboard.GetKeyStates( ...

  3. [转载]from __future__ import的用法

    一句话概况:这是为了在低版本python中使用高版本特性而引入的,最常用的就是print_function来实现在2.x中使用3.x中的print()命令,从而避免在切换版本时修改代码. https: ...

  4. python3.3.2中的关键字(转)

    The following identifiers are used as reserved words, or keywords of the language, and cannot be use ...

  5. Lab 色彩模型和取值范围

    L∈(0,100) a∈(-128,127) b∈(-128,127) opencv 的Lab数据对齐做了量化,使其处于0-255范围 L=L*2.55 a=a+128 b=b+128

  6. Spring讲解-----------表达式语言

    转自:https://blog.csdn.net/u011225629/article/details/47143083 5.1  概述5.1.1  概述       Spring表达式语言全称为“S ...

  7. MySQL四舍五入函数ROUND(x)、ROUND(x,y)和TRUNCATE(x,y)

    MySQL四舍五入函数ROUND(x) ROUND(x)函数返回最接近于参数x的整数,对x值进行四舍五入. 实例: 使用ROUND(x)函数对操作数进行四舍五入操作.SQL语句如下: mysql> ...

  8. C#中构建多线程应用程序[转] ----代码示例

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. python部署到服务器(2) 一一 nginx+uwsgi+Django

    参考菜鸟教程,https://blog.csdn.net/qq_42314550/article/details/81805328, 和 https://www.cnblogs.com/chenice ...

  10. python文件操作:文件处理案例

    储存一个文件,文件上有多个用户名,密码,做一个认证的流程程序,首先创建一个文件,文件上输入多个用户名,及对应的密码,然后让客户输入用户名和密码,进行用户名和密码核对,如果输入正确,则的认证成功,bre ...