相关链接
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5194
中文题面:http://blog.csdn.net/u014086857/article/details/44724335
解题报告
这题主要就是用到一个“期望的可加性”吧!
什么是可加性呢?
期望的和,等于和的期望
这里不需要期望之间相互独立
证明的话,你可以参见这里:http://blog.csdn.net/grooowing/article/details/45000205
于是这题我们分开考虑每一个位置出现01
的概率就好了
于是推一推式子发现答案至于n,m相关,于是写一个gcd就好了
Code
#include<bits/stdc++.h> #define LL long long using namespace std; inline int read() { char c=getchar(); int f=1,ret=0; while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();} while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();} return ret * f; } int GCD(int x, int y) { return y? GCD(y, x % y): x; } int main() { for (int n,m,gcd;~scanf("%d%d",&n,&m);) { gcd = GCD(n*m, n+m); printf("%d/%d\n", n*m/gcd, (n+m)/gcd); } return 0; }
A person essentially help to make seriously posts I would state. This is the first time I frequented your web page and thus far? I amazed with the research you made to make this particular publish incredible. Magnificent job!
Yeah bookmaking this wasn’t a bad determination outstanding post! .