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

建议使用的浏览器:

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

6861:Gaming of Co-prime Disallowance

Special Judge 特殊评判
题目描述
It is preferrable to read the pdf statment.

Cuber QQ and Little Fang are playing a game, called Gaming of Co-prime Disallowance (GCD).

To play GCD, two tables are needed. The game starts with $n$ cards on one table, and players take turns to move the cards to another table. In each turn, a player has to select one and only one card and move it. Let's assume that the players have moved $k$ cards, and there are $n-k$ cards left. The players who cannot make a move any more loses the game.

If one of the following two conditions happen, the players can no longer make a move:


  • There is no card on the original table, i.e., $k=n$.

  • On each card, there is a number. If the $k$ cards that have been moved have Greatest Common Divisor (GCD) equals 1, i.e., the $k$ numbers are co-prime, the game is over and the player who has made the last valid move wins the game.



To test the fairness of GCD, Cuber QQ and Little Fang plays completely randomly without any strategy at all. Help him calculate how likely he is going to win if Cuber QQ plays first.
输入解释
The first line of the input contains a single integer $T$ ($1\le T\le 150$), denoting the number of test cases.

Each of the next $T$ cases:


  • The first line contains an integer $n$ ($2\le n\le 100$).

  • The second line contains $n$ space-separated numbers $a_1,a_2,\cdots a_n$ ($1\le a_i\le 10^5$), the number on $n$ cards, respectively.



It is guaranteed that $\sum n \le 8~000$.
输出解释
For each test case, output one line contains a real number --- the probability that Cuber QQ will win the game.

Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.

Hint

For the first sample:

Cuber QQ will win if the players take turns to select the number in this way : $2,1$ ; $2,3$ ; $3,1$ ; $3,2$; $3,4$ ;$4,1$ ; $4,3$

So the probability that Cuber QQ will win the game is $\frac{1}{4}\cdot \frac{1}{3}\times 4+\frac{1}{4}=\frac{7}{12}$
输入样例
2
4
1 2 3 4
4
1 2 4 8
输出样例
0.583333333
0.500000000
来自杭电HDUOJ的附加信息
Recommend IceyWang

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

源链接: HDU-6861

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

共提交 0

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