7583: Gaming of Co-prime Disallowance

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

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≤T≤150), denoting the number of test cases.
Each of the next T cases:

  • The first line contains an integer n (2≤n≤100).

  • The second line contains n space-separated numbers a1,a2,⋯an (1≤ai≤105), the number on n cards, respectively.


It is guaranteed that ∑n≤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.


输入样例 复制

2
4
1 2 3 4
4
1 2 4 8

输出样例 复制

0.583333333
0.500000000

数据范围与提示

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 14⋅13×4+14=712
 

分类标签