F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Gaming of Co-prime Disallowance

Time Limit: 3000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 293    Accepted Submission(s): 96
Special Judge


Problem Description
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.
 

Input
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$.
 

Output
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}$
 

Sample Input
2 4 1 2 3 4 4 1 2 4 8
 

Sample Output
0.583333333 0.500000000
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-25 22:56:16, Gzip enabled