hdu5194DZY Loves Balls 期望

//n个黑球,m个白球,第i个数为白球si = 0,为黑球si = 1;

//求这个串s中出现01的期望

//期望是可以加的

//那么对于第i个位置出现0第i+1出现1的概率为(n/(n+m))*(m/(n+m-1))

//那么期望为n*m/(n+m-1)

#include<cstdio>

#include<cstring>

#include<iostream>

using namespace std ;

int gcd(int a , int b)

{

if(b == 0)

return a ;

return gcd(b  , a%b) ;

}

int main()

{

int n , m ;

while(~scanf("%d%d" , &n , &m))

{

int c = gcd(n*m , n+m) ;

printf("%d/%d\n" , n*m/c , (n+m)/c) ;

}

return 0 ;

}

时间: 2024-08-01 22:27:01

hdu5194DZY Loves Balls 期望的相关文章

HDU-5194-DZY Loves Balls(BestCoder Round # 35 )

DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 374    Accepted Submission(s): 205 Problem Description There are n black balls and m white balls in the big box. Now, DZY starts

hdu5194 DZY Loves Balls 【概率论 or 搜索】

//yy:那天考完概率论,上网无聊搜个期望可加性就搜到这题,看到以后感觉特别亲和,挺有意思的. hdu5194 DZY Loves Balls [概率论 or 搜索] 题意: 一个盒子里有n个黑球和m个白球[n,m≤12].每次随机从盒子里取走一个球,取了n+m次后,刚好取完.现在用一种方法生成了一个随机的01串S[1-(n+m)],如果第i次取出的球是黑色的,那么S[i]=1,如果是白色的,那么S[i]=0.求'01'在S串中出现的期望次数. 题解: 求出在第i个位置上出现0,第i+1个位置上

Hdoj 5194 DZY Loves Balls 【打表】+【STL】

DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 394    Accepted Submission(s): 221 Problem Description There are n black balls and m white balls in the big box. Now, DZY starts

hdu-5645 DZY Loves Balls(水题)

题目链接: DZY Loves Balls Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 105    Accepted Submission(s): 75 Problem Description DZY loves playing balls. He has n balls in a big box. On each ball

HDU 5570 balls 期望 数学

balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 Description There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+ai,m. If the number of b

HDU5194 DZY Loves Balls【排列组合】

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5194 题目大意: 袋子里有N个黑球.M个白球.用1表示取出来的是黑球,0表示取出来的是白球.不放回 的从袋子里取出这N+M个球.求相邻取出的两个球第一个球白球,第二个球是黑球的期望 次数是多少,即出现"01"的期望次数是多少. 思路: 考虑期望可加.第i(1<=i<=N+M)个位置上出现白球的概率为M/(M+N),则i+1个位置上 出现黑球的概率为N/(M+N-1).因为白球

hdu 5194 DZY Loves Balls

Problem Description There are n black balls and m white balls in the big box.Now, DZY starts to randomly pick out the balls one by one. It forms a sequence S. If at the i-th operation, DZY takes out the black ball, Si=1, otherwise Si=0.DZY wants to k

HDU 5194 DZY Loves Balls(概率)

Problem Description: There are n black balls and m white balls in the big box. Now, DZY starts to randomly pick out the balls one by one. It forms a sequence S. If at the i-th operation, DZY takes out the black ball, Si=1, otherwise Si=0. DZY wants t

BestCoder Round #35(DZY Loves Balls-暴力dp)

DZY Loves Balls Accepts: 371 Submissions: 988 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description There are n  black balls and m  white balls in the big box. Now, DZY starts to randomly pick out the ba