当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6710:Kaguya

题目描述
One day, the student council secretary Fujiwara Chika asked a question from Shinomiya Kaguya: there are n nodes on the left side of a bipartite graph and m nodes on the right side. The probability of 0.5 between any two nodes on different sides has a two-way edge. She wants to know what is the expected distance between a left node and a right node? (The distance between two nodes is the minimum number of edges that must pass. If the two nodes are not connected, their distance is regarded as 0.) It is well known that Shinomiya Kaguya is an IT rookie, and this is why Shinomiya Kaguya is stumped. Seeing that Fujiwara Chika is about to win, Shinomiya Kaguya, who is cute and arrogant, asks for help. Can you help Miss Kaguya to win?
输入解释
The input contains a $T(T \leq 30)$ to indicate the number of case, followed by T rows, three numbers per line representing $n(1 \leq n \leq 30), m(1 \leq m \leq 30), P(772,001\leq P \leq 1,000,000,007)$ indicating that there are n nodes on the left side, m nodes on the right side, and P is a **prime** number.
输出解释
The output has a total of T lines, and one answer per line indicates the desired distance between a pair of nodes(one left node and one right node). It can be shown that it can be represented as $\frac{A}{B}$ where A and B are coprime integers and B≠0(mod P). Print the value of $A*B^{-1}$(mod P).
输入样例
2
2 2 772001
2 2 1000000007
输出样例
241251
187500002
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6710

最后修改于 2020-10-25T23:33:42+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1500MS(Java/Others) 65536/65536K(Java/Others)