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. ...
随机推荐
- 关于Java中System.gc() 与System.runFinalization()
System.gc : 告诉垃圾收集器打算进行垃圾收集,而垃圾收集器进不进行收集是不确定的.只是建议进行回收 System.runFinalization(): 网上搜了一下很多人都说强制调用已经失 ...
- python 多线程队列
##Using Queue with multiprocessing – Chapter : Process Based Parallelism import multiprocessing impo ...
- Codeforces 899E - Segments Removal
899E - Segments Removal 思路:priority_queue+pair 代码: #include<bits/stdc++.h> using namespace std ...
- HTML中常见的其它标签
HTML中常见的其它标签 一.头标签部分 1.<title>:指定浏览器的标题栏显示的内容. 2.<base>: href 属性:指定网页中所有的超链接的目录.可以是本地目录, ...
- aria2c --enable-rpc --rpc-listen-all -D
在后台启动的方法,如题, 用来配合 web-aria2
- 20170523xlVBA多条件分类求和一例
Public Sub NextSeven_CodeFrame() Application.ScreenUpdating = False Application.DisplayAlerts = Fals ...
- 20170503xlVBA房地产数据分类连接
Sub NextSeven_CodeFrame4() Application.ScreenUpdating = False Application.DisplayAlerts = False Appl ...
- 当保存在Session中的对象,取出后,在外部发生改变时会怎样
return_reason_model model = new return_reason_model(); model.F_RetunrnReason = "; HttpContext.S ...
- Jzzhu and Numbers CodeForces - 449D (高维前缀和,容斥)
大意: 给定集合a, 求a的按位与和等于0的非空子集数. 首先由容斥可以得到 $ans = \sum \limits_{0\le x <2^{20}} (-1)^{\alpha} f_x$, 其 ...
- OC 对象调用属性或实例变量或方法的细节。
1.成员变量可以理解为所有在类的头上声明的,无论是@interface.@implementation下用大括号括起来或者是用@property声明的变量都可以称作这个类的 成员变量,只是在@impl ...