Counting the teams

All submissions for this problem are available.
The teacher in the Dystopian School for Politics and other Dirty Games (DSPDG) is training students in group activities. She feels that to really understand group behavior, students need to practice working in groups of different sizes. This is how she groups the students:
There are N students in the class, with roll numbers from 1 to N(2≤N≤10^{12}). The teacher generates using her laptop a random permutation of the roll numbers. The student with the roll number equal to the i^{th} number in the permutation is assigned as a "target" to the student with roll number as i (Note that "targetship" is not mutual. If 1 is the target for 2, 2 need not be the target for 1). If any student is assigned himself as the target, the teacher generates another permutation till no student is assigned himself.
The N students stand far from each other. Now student 1 goes and joins his target. After this, student 2 (and any student who is with him) joins 2's target. At the i^{th} step, student i and anyone who is already with him joins i's target. In case i's target is already with him, nothing is done.
By following this procedure, when all students have joined their targets, the class gets split into some groups. For example, assume that there are 6 students in the class and the permutation that has been generated is {2,4,5,6,3,1}. First, 1 goes and joins 2. Then 1 and 2 join 4. Then 3 joins 5. Then 1, 2 and 4 join 6. 5 is already with 3 and hence does not move. Similarly 6 is already with 1 and does not move. In the end, we have 2 teams : {1,2,4,6} and {3,5}
Given N, find out the expectation value of the number of teams that will be formed when the teacher groups the class in this fashion.
Input
First line of the input contains T(≤100), the number of test cases. Following this are T lines, each containing an integer N(2≤N≤10^{12}).
Output
For each N, output the expectation value of the number of groups formed. Output 6 digits after the decimal point while printing the expectation value
Example
Input: 2 3 4 Output: 1.000000 1.333333
Author:  razimantv 
Tags  razimantv 
Date Added:  6022011 
Time Limit:  4 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, GO, NODEJS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 