hdu-5810 Balls and Boxes(概率期望)
题目链接:
Balls and Boxes
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
where Xi is the number of balls in the ith box, and X¯ is the average number of balls in a box.
Your task is to find out the expected value of V.
The input is terminated by n = m = 0.
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <algorithm>
- #include <cmath>
- #include <bits/stdc++.h>
- #include <stack>
- #include <map>
- using namespace std;
- #define For(i,j,n) for(int i=j;i<=n;i++)
- #define mst(ss,b) memset(ss,b,sizeof(ss));
- typedef long long LL;
- template<class T> void read(T&num) {
- char CH; bool F=false;
- for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
- for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
- F && (num=-num);
- }
- int stk[70], tp;
- template<class T> inline void print(T p) {
- if(!p) { puts("0"); return; }
- while(p) stk[++ tp] = p%10, p/=10;
- while(tp) putchar(stk[tp--] + '0');
- putchar('\n');
- }
- const LL mod=1e9+7;
- const double PI=acos(-1.0);
- const LL inf=1e18;
- const int N=3e5+10;
- const int maxn=2e3+14;
- const double eps=1e-12;
- LL gcd(LL a,LL b)
- {
- if(b==0)return a;
- return gcd(b,a%b);
- }
- int main()
- {
- LL n,m;
- while(1)
- {
- read(n);read(m);
- if(n==0&&m==0)break;
- if(m==1)printf("0/1\n");
- else
- {
- LL temp=gcd(n*(m-1),m*m);
- printf("%lld/%lld\n",n*(m-1)/temp,m*m/temp);
- }
- }
- return 0;
- }
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; t ...
- HDU 5810 Balls and Boxes(盒子与球)
Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- HDU 5810 Balls and Boxes ——(数学,概率,方差)
官方题解看不太懂,参考了一些人的博客以后自己证明如下: 其中D(X)和E(X)的公式如下(参考自百度百科): 其中 p = 1 / m .(这是每一个单独事件发生的概率期望,在这里单独事件指的是一个球 ...
- HDU 5810 Balls and Boxes (找规律)
Balls and Boxes 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- HDU 5810 Balls and Boxes 数学
Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- hdu 5810 Balls and Boxes 二项分布
Balls and Boxes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5810 Balls and Boxes
n*(m-1)/(m*m) #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio&g ...
- hdu_5810:Balls and Boxes(期望)
这题似乎就是纯概率论.. E(V)=D(X_i)=npq (p=1/m,p+q=1) #include<bits/stdc++.h> using namespace std; typede ...
- 2016 多校联赛7 Balls and Boxes(概率期望)
Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. ...
随机推荐
- C指针的一些知识
原文:http://blog.csdn.net/soonfly/article/details/51131141 前言:复杂类型说明 要了解指针,多多少少会出现一些比较复杂的类型,所以我先介绍一下如何 ...
- 设置网站URL启动
当新建一个MVC WEB程序 当你打开一个视图按F5运行 这时候并且不能政策运行会出现与个错误 无法找到资源. 这时候站点的默认设置是 把这个个默认设置更改成 红色框框的地方为修改点 你以为这样就完了 ...
- django模型和字段
一个模型(model)就是一个单独的.确定的数据的信息源,包含了数据的字段和操作方法.通常,每个模型映射为一张数据库中的表. 基本的原则如下: 每个模型在Django中的存在形式为一个Python类 ...
- angular组件层次与军事指挥层级职责的联系
又继续读angular文档,发现自己之前理解还是有误.按官方文档的思路service不是属于component的,是属于module的.module才是负责完整领域逻辑的单位.demo的英雄编辑器给我 ...
- Hyper-v群集的仲裁模式配置依据
1,仲裁配置的原理 节点多数(推荐用于含有奇数个节点的群集) 可以承受的故障节点数为节点数的一半(四舍五入)减去一.例如,七个节点的群集可以承受三个节点出现故障. 节点和磁盘多数(推荐用于含有偶数个节 ...
- Codeforces 918C - The Monster
918C - The Monster 思路1: 右键在新窗口打开图片 代码: #include<bits/stdc++.h> using namespace std; #define ll ...
- springboot集成mybatis及mybatis generator工具使用
原文链接 前言mybatis是一个半自动化的orm框架,所谓半自动化就是mybaitis只支持数据库查出的数据映射到pojo类上,而实体到数据库的映射需要自己编写sql语句实现,相较于hibernat ...
- Android 7.0真实上手体验
Android 7.0真实上手体验 Android 7.0的首个开发者预览版发布了,支持的设备只有Nexus6.Nexus 5X.Nexus 6P.Nexus 9.Nexus Player.Pixel ...
- homestead 暴露接口到外网
laravel 官方推荐的运行环境是homestead,但homestead是个虚拟机,你自己访问没问题,给别人联调怎么办? 一个大型项目肯定不止一个人开发,这个时候就需要将你虚拟机上的接口暴露给外网 ...
- bzoj2154: Crash的数字表格 莫比乌斯反演
题意:求\(\sum_{i=1}^n \sum_{j=1}^m\frac{i*j}{gcd(i,j)}\) 题解:\(ans=\sum_{i=1}^n\sum_{j=1}^m \frac{i*j}{g ...