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

建议使用的浏览器:

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

5227:Tom and game

题目描述
Tom love to play games with Tony.

They think a orderly tetrad (t,i,j,k) is valid, when it satisfy,

1. $1\leq i,j,k\leq t$

2. Exist a positive integer s, which can divide both i and j, and is not smaller than k.

They prepare some tetrads, take turns to operate. When one can't operate, he loses. A valid operate is,

1. Choose a tetrad.

2. Change it to another valid tetrad which is smaller than it on dictionary order.

When compare two tetrads, compare the first element. If equal, compare the second element, and so on.

They think that prepare tetrads every time they want to play is troublesome. So they paint a tree, there is a tetrad on each point. When they want to play, Tom random choose a point P, Tony random choose a point Q. Then they copy down tetrads on points which are on the route connect P and Q (include P and Q), start the game.

Tom always operate first, he wants to know the probability of he wins.
输入解释
Multi test cases(about 8). For each case, the first line contains a positive integer n, indicates the number of points in the tree. In the next n-1 lines, each line contains two integers i and j, indicates there is an edge connect point i and point j. In the next n lines, the i-th line contains four integers, a、b、c、d, indicates the orderly tetrad on point i is (a,b,c,d).

$1\leq n\leq 10000;1\leq i,j\leq n;1\leq a,b,c,d\leq 10000$

It's assured that the tetrad on each point is valid.
输出解释
For each case, output a fraction "x/y", indicates the probability of Tom wins, x and y should be co-prime. If Tom is bound to fail, output "0/1".
输入样例
2
1 2
1 1 1 1
2 1 2 1
5
1 2
2 3
3 4
4 5
1 1 1 1
2 1 1 1
2 1 2 1
2 2 1 1
1 1 1 1
输出样例
3/4
3/5
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #40

源链接: HDU-5227

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

共提交 0

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