HUD 5194--DZY Loves Balls【规律】
来源:互联网 发布:阿里云如何查看发票 编辑:程序博客网 时间:2024/06/07 23:52
DZY Loves Balls
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 577 Accepted Submission(s): 317
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 sequenceS . If at the i -th operation, DZY takes out the black ball, Si=1 , otherwise Si=0 .
DZY wants to know the expected times that '01' occurs inS .
Now, DZY starts to randomly pick out the balls one by one. It forms a sequence
DZY wants to know the expected times that '01' occurs in
Input
The input consists several test cases. (TestCase≤150 )
The first line contains two integers,n ,m(1≤n,m≤12)
The first line contains two integers,
Output
For each case, output the corresponding result, the format isp/q (p and q are coprime)
Sample Input
1 12 3
Sample Output
1/26/5HintCase 1: S='01' or S='10', so the expected times = 1/2 = 1/2Case 2: S='00011' or S='00101' or S='00110' or S='01001' or S='01010' or S='01100' or S='10001' or S='10010' or S='10100' or S='11000',so the expected times = (1+2+1+2+2+1+1+1+1+0)/10 = 12/10 = 6/5
可能数据比较弱,找规律就水过了。
分子=m * n
分母=m + n
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int gcd(int a,int b){if(b == 0) return a;else return gcd(b, a % b);}int main (){int n,m;while(scanf("%d%d",&n, &m)!=EOF){int a = m * n;int b = m + n;printf("%d/%d\n", (m*n)/gcd(a,b),(m+n)/gcd(a,b));}return 0;}
0 0
- HUD 5194--DZY Loves Balls【规律】
- HDU 5194 DZY Loves Balls
- HDU 5194 DZY Loves Balls
- hdoj 5194 DZY Loves Balls
- HDU 5194 DZY Loves Balls
- HDOJ 5194 DZY Loves Balls
- hdu 5194 DZY Loves Balls (dp)
- HDU 5194——DZY Loves Balls
- HDOJ-5194-DZY Loves Balls 解题报告
- hdu 5194 DZY Loves Balls(组合数学)
- HDU 5194 DZY Loves Balls(期望可加性)
- HDU 5194 DZY Loves Balls(概率)
- 杭电5194DZY Loves Balls
- hdu DZY Loves Balls
- DZY Loves Balls
- DZY Loves Balls
- HDU5194 DZY Loves Balls【排列组合】
- HDU5645 DZY Loves Balls 数学
- Bootloader启动过程
- 八皇后问题
- 传智播客 Html基础知识学习笔记2
- Android.mk
- 图像频域滤波处理
- HUD 5194--DZY Loves Balls【规律】
- Android 手机返回键 退出应用
- hdoj 1159 Common Subsequence 【最大连续子序列】
- QT学习笔记
- DFS Permutations
- SDUT 2139 图结构练习——BFS——从起始点到目标点的最短步数(BFS + vector)
- hdu D-City 反向并查集
- sdut-2156(模拟,bfs)
- 传智播客 Html基础知识学习笔记